Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide overflow on elements with fixed position

Is there any way to hide the overflow of a fixed div with a container? I thought fixed inside fixed would do it, but it seems it's not the case. The only workaround I can think of is "inverted" masks: other fixed divs hiding everything around the one, but it'd be better if there are any other solutions.

Here's the fiddle: http://jsfiddle.net/pjFa6/1/

like image 564
Yisela Avatar asked Aug 13 '12 02:08

Yisela


People also ask

How do I keep my position fixed in HTML?

To create a fixed top menu, use position:fixed and top:0 . Note that the fixed menu will overlay your other content. To fix this, add a margin-top (to the content) that is equal or larger than the height of your menu.

What is the opposite of overflow hidden?

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.

Why sticky is not working CSS?

If you've ever tried sticky positioning, then you have probably wondered why CSS position: sticky is not working for your web design. It's because an ancestor element has one of the following values for the overflow property: hidden, scroll, or auto.


1 Answers

Unfortunately it seems to be impossible to nest a fixed element within another element (fixed or not) and expect the outer element to wrap it and hide any overflow.

The only thing I can think of is setting the inner div to position:absolute instead of fixed. Here is an example based on your jsfiddle: jsfiddle.net/pjFa6/15 .

like image 124
Jeemusu Avatar answered Sep 21 '22 02:09

Jeemusu