I'm not able to center an inner, position: absolute
element inside of an position: relative
element ( https://jsfiddle.net/qL0c8cau/ ):
html,body,div {margin:0;padding:0;}
.one {
position: relative;
margin: 50px auto;
width: 200px;
height: 100px;
background: #900;
}
.two {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: auto;
background: #0f0;
opacity: 0.3;
height: 160px;
width: 400px;
}
<div class="one">
<div class="two"></div>
</div>
I can't see what is wrong with it. I set everything correct, but it's not aligned horizontally for some reason.
What am I doing wrong here?