Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to put a child element behind its parent using css? [duplicate]

Tags:

javascript

css

I was wondering if there is a way to put child element behind its parent using css. I now z-index is not an option because the child elements inherits the z-index of their parents. But I want to know if there's a hack or anything I can use to get this done. Or if there's a javascript hack or anything.

Forgive the bad english.

like image 769
carcargi Avatar asked Feb 17 '23 05:02

carcargi


1 Answers

If the parent has no z-index and the child has negative z-index it works. Check here:

jsfiddle.net/L29d2/

html

<div class="big">
    <div class="small"></div>
</div>

css

.big {
background-color:red;
width:400px;
height:400px;
}
.small {
float:left;
position:absolute;
background-color:blue;
width:200px;
height:200px;
margin-left:300px;
z-index:-1;
}
like image 164
Sergio Avatar answered Apr 27 '23 03:04

Sergio