HTML CSS Bootstrap JavaScript jQuery MySQL PHP Data Mining

CSS Overflow

The overflow property specifies whether to clip content or add scrollbars when an element's content is too big to fit in a specified area.


Overflow Values

1. visible (Default)

The overflow is not clipped. It renders outside the element's box.

RedoHub is an amazing platform. This text is flowing right out of its intended container because we set overflow to visible!
div { overflow: visible; }

2. hidden

The overflow is clipped and becomes invisible.

This text is being cut off. You cannot see the rest of this sentence because the container is set to hide the overflow.
div { overflow: hidden; }

3. scroll

The overflow is clipped, and a scrollbar is added (both horizontally and vertically) to see the rest of the content.

You can manually scroll inside this box to read all of the content. Note that the scrollbars are always visible here.
div { overflow: scroll; }

4. auto

Similar to scroll, but it adds scrollbars only when necessary.

The browser will only show a scrollbar if this text is long enough to require it. This is the preferred method for most scrollable containers.
div { overflow: auto; }

Overflow-X and Overflow-Y

You can control the overflow for specific directions (horizontal vs vertical) separately.

div {
    overflow-x: hidden; /* Hide horizontal scroll */
    overflow-y: scroll; /* Force vertical scroll */
}

Tip: Use overflow: hidden on parent containers to automatically clear floated child elements (the clearfix hack).