The overflow property controls how extra content exceeding the bounding box of an element is rendered. It can be used in conjunction with an element that has a fixed width and height, to eliminate text-induced page distortion.
Overview tablevisible
overflow
overflow: <overflow-x> <overflow-y>
overflow: auto
overflow: hidden
overflow: no-content
overflow: no-display
overflow: scroll
overflow: visible
Add different behavior for paragraphs via the overflow
property.
.hidden {
overflow: hidden;
}
.scroll {
overflow: scroll;
}
.auto {
overflow: auto;
}
.visible {
overflow: visible;
}
p {
height: 60px;
}
Clearing floats with overflow
.clear {
overflow: hidden;
background: green;
}
.floating {
float: left;
width: 200px;
}
Two values for overflow
.
.overflow-y {
overflow: hidden auto;
height: 30px;
}
Usage
The overflow CSS property specifies whether to clip content, render scroll bars or display overflow content of a block-level element.
The overflow
property takes up to two values. If given one value, both overflow-x
and overflow-y
are set to that value. If given two values, the first value applies to overflow-x
and the second applies to overflow-y
.
Using the overflow property with a value different than visible, its default, will create a new block formatting context. This is technically necessary as if a float would intersect with the scrolling element it would force to rewrap the content of the scrollable element around intruding floats. The rewrap would happen after each scroll step and would be lead to a far too slow scrolling experience. Note that, by programmatically setting scrollTop to the relevant HTML element, even when overflow has the hidden value an element may need to scroll.
NotesThe default value for the html
element is auto
. Setting the overflow
property to visible
causes the content to clip to the size of the window or frame that contains the object.
Specifying two values is currently not supported by browsers.
Firefox (Gecko) NotesThrough Firefox 3.6 (Gecko 1.9.2), the overflow property is incorrectly applied to table-group elements (<thead> , <tbody> , <tfoot>). This behavior is corrected in later versions.
Internet Explorer NotesInternet Explorer 4 to 6 enlarges an element with overflow: visible
(default value) to fit the content in it. height/width behaves like min-height/min-width.
Mozilla Developer Network : Article
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4