English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Complete List of CSS Properties

CSS3 overflow-Usage and examples of the property

overflow-The CSS property specifies what happens when content overflows the left and right edges of the element's content area: whether to clip the content, display a scrollbar, or show the overflow content.

下表为此属性的用法说明和版本历史记录,以及该属性在javascript脚本中的使用语法。

The following table provides usage instructions and version history of this attribute, as well as its usage syntax in JavaScript scripts.visible
Default value:Applicable to:-Block, inline
Block and flex containersInheritance:
NoneAnimatable:No. Please see.
Animation properties CSS3Version:
New feature ofobject.style.overflowX="scroll"

Overflow x syntax

The syntax of this attribute is as follows:

overflow-x: visible | hidden | scroll | auto | initial | inherit

The following examples demonstrate how to use overflow-x attribute.

  div {
   width: 400px;
   height: 300px;
   overflow-x: scroll;
  }
Test to see‹/›

Attribute value

The following table describes the value of this attribute.

ValueDescription
visibleThe content is not clipped; it will be rendered outside the element's box, so it may overlap with other content. This is the default value.
hiddenThe content of the overflow element's box will be clipped, and the remaining content will be invisible.
scrollThe overflow content is clipped as if hidden, but provides a scrolling mechanism to access the overflowed content.
autoIf the content overflows the element's box, it will provide a scrollbar to view the remaining content.
initialSet this property to its default value.
inheritIf specified, the associated elements adopt the overflow of their parent element-x attribute value.

Browser compatibility

overflow-The compatibility of the x attribute of the browser, the numbers in the table below represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.

  • Firefox 1.5Above

  • Google Chrome1+

  • Internet Explorer 9+

  • Apple Safari 3+

  • Opera 9.5+

Warning: Internet Explorer 7and earlier versions do not support this overflow-x property. IE8supports this attribute but requires Microsoft-specific
-ms-prefix (e.g.-ms-overflow-x). In IE9and higher versions are supported.

For further reading

Please refer to the following tutorials:CSS Overflow.

Related properties:overflow,overflow-y,clip,word-wrap.