Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML/CSS hack to allow overflow-x: auto & overflow-y: visible? [duplicate]

Tags:

html

css

overflow

I have a 400px x 400px div that I want to scroll vertically. So I'm setting overflow-y: auto. But occasionally, I want the content inside the div to overflow-x:visible.

This doesn't work. I think it's because you can't set different overflow values if one of them is visible.

True?

Otherwise, is there a decent css/js fix for this? I noticed flow app appends a calculated, absolutely-position div to the body whenever a situation like this occurs: http://cl.ly/32392W0U2t1y2Q103X2d. Is this the best solution? And are there any plugins/tutorials to look at?

like image 400
For Sc Avatar asked Jan 26 '12 05:01

For Sc


People also ask

How do I bypass overflow hidden in CSS?

Use overflow: hidden instead. Use overflow-x : scroll and overflow-y : hidden , or overflow: scroll hidden instead. Use overflow-x : hidden and overflow-y : scroll , or overflow: hidden scroll instead. Use overflow: clip instead.

How do you overcome overflow in HTML?

For example, overflow: scroll hidden would set overflow-x to scroll and overflow-y to hidden . If you only want scrollbars to appear when there is more content than can fit in the box, use overflow: auto . This allows the browser to determine if it should display scrollbars.

How do you overflow an element in CSS?

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.


1 Answers

You can’t set different overflow values if one of them is visible; the CSS3 Box Model draft says this in section on overflow: “The computed values of ‘overflow-x’ and ‘overflow-y’ are the same as their specified values, except that some combinations with ‘visible’ are not possible: if one is specified as ‘visible’ and the other is ‘scroll’ or ‘auto’, then ‘visible’ is set to ‘auto’.”

Regarding workarounds, you would first need to decide what the desired behavior is. When you have a scroll bar on the right, how would overflow-x: visible work? Should the overflowing content continue on the right of the scroll bar somehow? This would be difficult to arrange. Or should the scroll bar move to the right?

like image 161
Jukka K. Korpela Avatar answered Oct 13 '22 05:10

Jukka K. Korpela