Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make div go behind another div?

Tags:

html

css

I am trying to make the "box-left-mini" go in front of the div which is below.

<div class="box-left-mini">    this div is infront     <div style="background-image:url(/images/hotcampaigns/campaign-sample.png);height:100px;width:100px;">         this div is behind     </div> </div> 

The CSS for box-left-mini is:

.box-left-mini {     float:left;     background-image:url(website-content/hotcampaign.png);     width:292px;     height:141px; } 
like image 880
Jayden Avatar asked Oct 24 '13 09:10

Jayden


1 Answers

http://jsfiddle.net/f2znvn4f/


HTML

<div class="box-left-mini">     <div class="front"><span>this is in front</span></div>     <div class="behind_container">         <div class="behind">behind</div>             </div> </div> 

CSS

.box-left-mini{     float:left;     background-image:url(website-content/hotcampaign.png);     width:292px;     height:141px; }  .box-left-mini .front {     display: block;     z-index: 5;     position: relative; } .box-left-mini .front span {     background: #fff }  .box-left-mini .behind_container {     background-color: #ff0;     position: relative;     top: -18px; } .box-left-mini .behind {     display: block;     z-index: 3; } 

The reason you're getting so many different answers is because you've not explained what you want to do exactly. All the answers you get with code will be programmatically correct, but it's all down to what you want to achieve

like image 158
Richard Peck Avatar answered Oct 09 '22 08:10

Richard Peck