html - Div not being centre aligned inside another div -
i can't seem centre align div(title) sits inside div.
html
<div class="wrapper"> <div id="header"> <div class="title">home</div> </div> </div>
css
#header { position:relative; width:1200px; height:400px; margin:auto; border:1px solid red; } .title { position:absolute; width:1000px; height:140px; background-color:red; margin:auto; }
remove position: absolute
, works perfectly.
position: absolute necessary when need specific placement outside of normal document flow. in case, nothing special needed apart automatic left , right margins, have.
Comments
Post a Comment