overflow

定义和用法

overflow 属性规定如何处理如何处理不符合元素框的内容。

语法:

Object.style.overflow=visible|hidden|scroll|auto

可能的值

描述
visible 内容不会被修剪,会呈现在元素框之外。
hidden 内容会被修剪,但是浏览器不会显示供查看内容的滚动条。
scroll 内容会被修剪,但是浏览器会显示滚动条以便查看其余的内容。
auto 由浏览器决定如何显示。如果需要,则显示滚动条。

实例

本例使用 overflow 来显示溢出元素框的内容:

<html>
<head>
<style type="text/">
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>

发表评论

邮箱地址不会被公开。 必填项已用*标注

click to changeSecurity Code