html - overlapping 1 div over another using z-index -


i trying overlap div2 on div1

http://jsfiddle.net/user1212/qslvb/

<div id="div1"></div> <div id="div2"></div>  #div1{     width: 200px;     height: 200px;     background-color: olive;     float: right;     position: relative;     z-index: 1; } #div2{     width:100px;     height: 100px;     background-color: orange;     float: right;     position: relative;     z-index: 2; } 

i need both float right.

there's number of ways them overlap.

first example http://jsfiddle.net/qslvb/3/

use negative margins.

#div2{     margin: 20px -100px 0 0; } 

second example http://jsfiddle.net/qslvb/4/

just make div child of other one. in case z-index not anything, since child shown above parent.

<div id="div1"> <div id="div2"></div> </div> 

also, can go other routes , use position: absolute instead , top/right values, etc.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -