How to make div appear in front of another?

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> ?


Solution 1:

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.

Solution 2:

You can set the z-index in css

<div style="z-index: -1"></div>

Solution 3:

In order an element to appear in front of another you have to give higher z-index to the front element, and lower z-index to the back element, also you should indicate position: absolute/fixed...

Example:

<div style="z-index:100; position: fixed;">Hello</div>
<div style="z-index: -1;">World</div>

Solution 4:

The black div will display the full 500px unless overflow:hidden is set on the 100px li

Solution 5:

Upper div use higher z-index and lower div use lower z-index then use absolute/fixed/relative position