html - Center a div inside another div -


i'm trying set div centered inside div.

this html page:

<body> <div id="divparent">     <div id="divheader" >         <div id="divheadertext">         </div>     </div>     <div id="divbody">     </div> </div> </body> 

and style:

#divheader {     background-color: #c7c7c7;     font-family: verdana, geneva, tahoma, sans-serif;     height: 80px;     margin-bottom: 2px; } #divbody {     background-image: url('images/gradientbackground.png');     background-repeat: repeat-x;     height: 300px; } #divheadertext {     margin: auto;     width: 90%;     height: 80%;     background-color: #00ff00; } 

why smallest div doesn't left space on top?

your question unclear.

if you're trying vertically center #divheadertext within #divheader, try adding margin-top: 13px;.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -