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

Popular posts from this blog

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -

c# - MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(3243,9): error MSB4094 -