When you use transform
on div, absolute positioning not working as you expected anymore, and seems like it needs to be calculated manually. For instance when you want your div to be at the bottom of container you do:
div{
position:absolute;
bottom:0%;
}
But if you transform this div like -webkit-transform:rotateX(angle);
it won't be at the bottom of container. Is places somewhere in between of container depends of its size.
I create jsfiddle to illustrate this, and also show what i'm trying to achive: http://jsfiddle.net/9NHJt/
Here's the code i use:
<div class="container"> height: 150px;
<div class="inner"></div>
</div>
<div class="container" style="height:250px"> height: 250px;
<div class="inner"></div>
</div>
<div class="container"> desired result
<div class="inner" style="bottom:-19px"></div>
</div>
.container{
margin-top:30px;
position:relative;
width:500px;
height:150px;
-webkit-perspective:1000px;
border:1px solid black
}
.inner{
-webkit-transform:rotateX(45deg);
background:rgba(238, 238, 238, 0.8);
border:1px dashed black;
position:absolute;
width:100%;
height:100%;
bottom:0%; /* Needs to be calculated */
}
So, is there a way to fix this without javascript? Or how to calculate correct bottom position with js?