當一個元素的內容可能大於分配給它的空間量時,應該怎麼做?
使用 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