Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make div appear in front of another?

Tags:

html

css

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

like image 968
zac1987 Avatar asked Mar 30 '11 00:03

zac1987


People also ask

How do you make a div appear over another?

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 ).

How do I bring a div front in CSS?

Div/image with higher z-index value takes front place and lower would stay behind.


2 Answers

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.

like image 56
aroth Avatar answered Sep 24 '22 02:09

aroth


You can set the z-index in css

<div style="z-index: -1"></div> 
like image 30
Greg Randall Avatar answered Sep 23 '22 02:09

Greg Randall