I have child element which need to be positioned absolute
with the grandparent. The problem is that the parent is also positioned absolutely.
I can't use JavaScript. How can I achieve this with just pure CSS?
JSFiddle Demo
<div class="col-md-6 gp">
<div class="col-md-4 p">
<div class="col-md-2 c"> position me w.r.t to .gp</div>
</div>
</div>
.gp { height : 200px; position: relative; }
.p {
height : 100px; width: 250px;
position :absolute;
top : 50px; left: 50px;
}
.c { position: absolute; height: 50px; }
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…