CSS Overflow || Bcis Notes

CSS Overflow

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

The overflow property has the following values:

  • visible – Default. The overflow is not clipped. The content renders outside the element’s box
  • hidden – The overflow is clipped, and the rest of the content will be invisible
  • scroll – the overflow is clipped, and a scrollbar is added to see the rest of the content
  • auto – Similar to scroll, but it adds scrollbars only when necessary

 

1. overflow: visible

By default, the overflow is visible, meaning that it is not clipped and it renders outside the element’s box:

CODE:

 

Result:

2. overflow: hidden

With the hidden value, the overflow is clipped, and the rest of the content is hidden:

CODE:

 

Result:

3. overflow: scroll
Setting the value to scroll, the overflow is clipped and a scrollbar is added to scroll inside the box. Note that this will add a scrollbar both horizontally and vertically (even if you do not need it):

CODE:

 

Result:

4. overflow: auto
The auto value is similar to scroll, but it adds scrollbars only when necessary:

CODE:

 

Result:

                                   All CSS Overflow Properties

 

You may also like:  CSS Position

 

Leave a Reply

Your email address will not be published. Required fields are marked *