CSS overflow-x Property

Description

The overflow-x property These properties specifies the handling of overflow in the horizontal direction (i.e., overflow from the left and right sides of the box).

Initial value
visible
Applies to
Block containers, flex containers and grid containers
Inherited
No
Media
Visual
Computed value
As specified
Animatable
No
CSS Version
CSS3
JavaScript syntax
object.style.overflowX

Syntax

overflow-x: visible | hidden | scroll | auto

Values

  • visibleContent is not clipped and scroll bars are not added. Elements are clipped to the size of the containing window or frame.
  • hiddenContent that exceeds the dimensions of the object is not shown.
  • scrollContent is clipped and scroll bars are added, even if the content does not exceed the dimensions of the object.
  • autoContent is clipped and scrolling is added only when necessary.

Example

<div class="test"> visible
<img src="images/tech.gif" alt="">
</div>
<div class="test2"> hidden
<img src="images/tech.gif" alt="">
</div>
<div class="test3"> scroll
<img src="images/tech.gif" alt="">
</div>
<div class="test4"> auto
<img src="images/tech.gif" alt="">
</div>
div {
   display: inline-block; 
   margin-right: 30px;
   width: 100px; 
   height: 100px;
   border: 2px solid blue; 
}
img {
   width: 125px;
   height: 125px;
}
.test {
   overflow-x: visible;
   overflow-y: visible;
}
.test2 {
   overflow-x: hidden;
   overflow-y: hidden; 
}
.test3 {
   overflow-x: scroll;
   overflow-y: scroll;
}
.test4 {
   overflow-x: auto;
   overflow-y: auto; 
}

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
51213.59.53
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
1184Yes1Yes

Last updated by CSSPortal on: 3rd November 2019