HTML DOM overflow 屬性
定義和用法
overflow 屬性規(guī)定如何處理如何處理不符合元素框的內(nèi)容。
語法:
Object.style.overflow=visible|hidden|scroll|auto
可能的值
值 | 描述 |
---|---|
visible | 內(nèi)容不會(huì)被修剪,會(huì)呈現(xiàn)在元素框之外。 |
hidden | 內(nèi)容會(huì)被修剪,但是瀏覽器不會(huì)顯示供查看內(nèi)容的滾動(dòng)條。 |
scroll | 內(nèi)容會(huì)被修剪,但是瀏覽器會(huì)顯示滾動(dòng)條以便查看其余的內(nèi)容。 |
auto | 由瀏覽器決定如何顯示。如果需要,則顯示滾動(dòng)條。 |
實(shí)例
本例使用 overflow 來顯示溢出元素框的內(nèi)容:
<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>