Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Css overflow-y: how to show only when needed

Tags:

html

css

I'm adding the overflow-y parameter to "scroll" in my css in order to have scrolling bar in case of overflow..

My problem is that if the content is not overflowing - i'm still having the blank scroll bar.

How can i set the overflow to show the scrolling bar only when needed ?

like image 869
Asaf Nevo Avatar asked Jan 23 '14 14:01

Asaf Nevo


2 Answers

You can set it to auto

overflow-y : auto;

It will only show scroll bar in case of overflow.

Refer : What browsers support `overflow-y`?

like image 166
Pranav C Balan Avatar answered Oct 02 '22 01:10

Pranav C Balan


as mentioned before, the way to do this is by setting:

overflow-y: auto

When setting the property to auto, the browser determines how to handle the content, but generally, the scrollbar appears when it is required.

You would greatly benefit from learning more about the overflow property. There is a great article here that explains it nicely.

like image 21
Nesha Zoric Avatar answered Oct 02 '22 01:10

Nesha Zoric