当一个元素的内容可能大于分配给它的空间量时,应该怎么做?
使用 CSS overflow 属性来解决内容超过已分配空间的问题。您可以尝试运行以下代码来解决问题:
示例
<html>
<head>
</head>
<style>
.scroll{
display:block;
border: 2px solid green;
padding:10px;
margin-top:10px;
width:300px;
height:50px;
overflow:scroll;
}
.auto{
display:block;
border: 2px solid green;
padding:10px;
margin-top:10px;
width:300px;
height:50px;
overflow:auto;
}
</style>
<body>
<p>Example of scroll value:</p>
<div class = "scroll">
This is Demo Content. This is Demo Content. This is Demo Content.
This is Demo Content. This is Demo Content. This is Demo Content.
This is Demo Content. This is Demo Content. This is Demo Content.
This is Demo Content. This is Demo Content. This is Demo Content.
</div>
<br />
</body>
</html>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP