📜  CSS Overflow属性

📅  最后修改于: 2020-11-04 06:43:00             🧑  作者: Mango

CSS Overflow属性

CSS Overflow属性指定了在其块级容器溢出时如何处理内容。

我们知道页面上的每个元素都是一个矩形框,这些框的大小,位置和行为都通过CSS进行控制。

让我们举个例子:如果不设置框的高度,则框的大小将与内容一样大。但是,如果您设置框的特定高度或宽度,而里面的内容无法容纳,那将会发生什么。 CSS溢出属性用于克服此问题。它指定是剪切内容,渲染滚动条还是仅显示内容。

CSS Overflow属性值

Value Description
visible It specifies that overflow is not clipped. it renders outside the element’s box.this is a default value.
hidden It specifies that the overflow is clipped, and rest of the content will be invisible.
scroll It specifies that the overflow is clipped, and a scroll bar is used to see the rest of the content.
auto It specifies that if overflow is clipped, a scroll bar is needed to see the rest of the content.
inherit It inherits the property from its parent element.
initial It is used to set the property to its initial value.

CSS Overflow属性示例

让我们看一个简单的CSS Overflow属性。







The overflow property specifies what to do if the content of an element exceeds the size of the element's box.

overflow:scroll

You can use the overflow property when you want to have better control of the layout. The default value is visible.

overflow:hidden

输出:

Overflow属性指定如果元素的内容超过元素框的大小该怎么办。

overflow:scroll

You can use the overflow property when you want to have better control of the layout. The default value is visible.

overflow:hidden

You can use the overflow property when you want to have better control of the layout. The default value is visible.