Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent a child element from clipping if the parent's overflow is not visible?

Once assigning overflow with a value other than visible, all its child elements will be clipped. It is the purpose of the overflow property. However, I have to make one of the child elements to be 'floated' and not clipped (like a popup) -- just one of them; not all. Is it possible?

Take the following as an example. Is there any CSS setting that does not clip the yellow div, while clipping the blue element? (Currently they are both clipped)

<div style="position:absolute;width:100px;height:50px;overflow:hidden;border:1px solid black">
 <div style="top:30px;width:50px;height:100px;background:yellow">
 </div>
 <div style="position:absolute;left:50px;top:0;width:50px;height:100px;background:blue">
 </div>
</div>

The code can be also found at http://jsfiddle.net/kZBxD/

like image 509
Tom Yeh Avatar asked Mar 17 '12 07:03

Tom Yeh


People also ask

How can we prevent child element affected by parents hover state?

You can add pointer-events:none; to your child element - but it will not respond to it's own hover styles either.

Which flex property will use to prevent child element to flow out of parent width?

To override this behavior, use min-width: 0 or overflow: hidden .


1 Answers

Do you need something like this:

check this fiddle : http://jsfiddle.net/kZBxD/3/

<div style="position:absolute;width:100px;height:50px;overflow:hidden;border:1px solid black">
<div style=" position:fixed;width:50px;height:100px;background:yellow"></div>

like image 156
Jack Avatar answered Oct 18 '22 14:10

Jack