HTML DOM overflow 屬性
定義和用法
overflow 屬性規(guī)定如何處理如何處理不符合元素框的內容。
語法:
Object.style.overflow=visible|hidden|scroll|auto
可能的值
| 值 | 描述 |
|---|---|
| visible | 內容不會被修剪,會呈現(xiàn)在元素框之外。 |
| hidden | 內容會被修剪,但是瀏覽器不會顯示供查看內容的滾動條。 |
| scroll | 內容會被修剪,但是瀏覽器會顯示滾動條以便查看其余的內容。 |
| auto | 由瀏覽器決定如何顯示。如果需要,則顯示滾動條。 |
實例
本例使用 overflow 來顯示溢出元素框的內容:
<html>
<head>
<style type="text/css">
div
{
border:thin solid green;
width:100px;
height:100px;
}
</style>
<script type="text/javascript">
function hideOverflow()
{
document.getElementById("div1").style.overflow="hidden";
}
</script>
</head>
<body>
<div id="div1">
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
</div>
<br />
<input type="button" onclick="hideOverflow()"
value="Hide overflow" />
</body>
</html>