Posts Tagged with relative

Displaying 1-1 of 1 result.
Resolved: How do I horizontally center an absolute positioned element inside a 100% width div?
posted by admin on January 1, 2016
In the example below, #logo is positioned absolutely and I need it to be horizontally centered within #header. Normally, I would do a margin:0 auto for relatively positioned elements but I am stuck here. Can someone show me the way?

HTML

<div id="header">
<div id="logo"></div>
</div>


CSS

#header {
background:black;
height:50px;
width:100%;
}

#logo {
background:red;
height:50px;
position:absolute;
width:50px
}
Read more