Please refer to the codes below :
<ul> <li style="height:100px; overflow:hidden;"> <div style="height:500px; background-color:black;"> </div> </li> </ul>
From the codes above, we know that we can only see 100px height of black background. My question is how can we see 500px height of <div>
black background? In other words, how can I make the <div>
appear in front of <li>
?
You can use the CSS position property in combination with the z-index property to overlay an individual div over another div element. The z-index property determines the stacking order for positioned elements (i.e. elements whose position value is one of absolute , fixed , or relative ).
Div/image with higher z-index value takes front place and lower would stay behind.
Use the CSS z-index property. Elements with a greater z-index value are positioned in front of elements with smaller z-index values.
Note that for this to work, you also need to set a position
style (position:absolute
, position:relative
, or position:fixed
) on both/all of the elements you want to order.
You can set the z-index in css
<div style="z-index: -1"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With