How do you Horizontally center align a DIV that is absolutely positioned in another DIV ?
HTML
<div style="width:250px;height:250px;background:red;position:relative;">
<div style="width:100px;height:100px;background:blue;position:absolute;"></div>
</div>
Thank You
My answer works only if the background of the inner
divhas no background color. As your example does, I add a thirddiv. The second one is for the centering, the third one is for the coloring.The important thing to notice here is:
padding-left:50%;margin-left:-50px;.-50pxbeing half of you div’s width.