Home > Article > Web Front-end > Share CSS overflow overflow example tutorial
Clip the left/right edge of the content in the div element - if it overflows the content area of the element:
div { overflow-x:hidden; }
Browser support
All major browsers support the overflow-x attribute.
Note: The overflow-x attribute does not work correctly in IE8 and earlier browsers.
Definition and Usage
The overflow-x attribute specifies whether to clip the left/right edges of the content - if it overflows the element's content area.
overflow-X | overflow-y
The properties of overflow-x and overflow-y were originally properties independently developed by IE browser. It was later adopted and standardized by CSS3. overflow-x is mainly used to define the shearing of horizontal content overflow, and overflow-y is mainly used to define the shearing of vertical content overflow
[Note] If the overflow-x and overflow-y values The same is equivalent to overflow. If the overflow-x and overflow-y values are different, and one of the values is explicitly set to visible or is not set, the default is visible, and the other value is a non-visible value. The visible value will be reset to auto
Value: visible | hidden | scroll | auto | inherit | no-display | no-content
Initial value: visible
Applies to: block-level elements, replacement elements, table cells
Inheritance: None
visible
The content of the element is also visible outside the element box
[Note 1] The containing block of the element in IE6-browser will be extended so that its excess content can be wrapped
.box{ height: 200px; width: 200px; background-color: lightgreen; }.in{ width: 300px; height: 100px; background-color: lightblue; }
9890cd3db8af2c13be66110fccb4c149 b2088663f68f0a6fc33fb2dc4ee21a5394b3e26ee717c64999d7867364b1b4a394b3e26ee717c64999d7867364b1b4a3
The picture on the left is IE6-browser, the picture on the right is other browsers
## [Note 2] There is a bug in the buttons of IE7-browser (including bb9345e55eb71822850ff156dfde57c8 and 8e03557d3950bf880a2e4583affa2fab). When there is more text on the button , the larger the padding on both sides of the button. This problem can be solved by setting overflow:visible
The picture on the left shows the default situation, and the picture on the right shows the situation after setting overflowIf the content is clipped, the browser will display scroll bars In order to view the rest of the content
[Note] For general browsers, 100db36a723c770d327fc0aef2ce13b1 and 4750256ae76b6b9d804861d8f69e79d3 have the overflow:auto attribute by default. But IE7-browser is different. There is a vertical scroll bar by default
//IE7-浏览器 html{overflow-y: scroll;}//其他浏览器 html{overflow: auto;}//去除页面默认滚动条 html{overflow: hidden;}
The content of the element will be in the element box Clipping at the border, but the browser will display scroll bars to view the rest of the content
[Note] Firefox and IE8+ browsers have a missing
padding-bottomphenomenon when using overflow:scroll or auto.
.box{ width: 100px; height: 100px; padding: 50px; background-color: pink; overflow:scroll; }.in{ width: 100px; height: 200px; background-color: lightgreen; }
9890cd3db8af2c13be66110fccb4c149 b2088663f68f0a6fc33fb2dc4ee21a5394b3e26ee717c64999d7867364b1b4a394b3e26ee717c64999d7867364b1b4a3
The above is the detailed content of Share CSS overflow overflow example tutorial. For more information, please follow other related articles on the PHP Chinese website!