Align Vertical and Horizontal Align
I am trying to align a box VxH Center but I seem to be getting it just a bit off:
HTML:
<div id="wrapper">
<header>
<div id="logoWrapper">
<div class="logo">Logo Here </div><!-- Logo End -->
</div><!-- Logo Wrapper -->
</header>
</div><!-- Wrapper End -->
CSS:
![#wrapper{
width:955px;
margin:auto;
}
html body{
background:#F1FF29;
}
#logoWrapper{
width:429px;
height:179px;
position:absolute;
left:50%;
top:50%;
margin-left:-100px;
margin-top:-50px;
}
.logo{
display:block;
background:red;
width:429px;
height:179px;
}]
Image: http://i.stac开发者_开发问答k.imgur.com/rZ2ng.png
Change your margins for #logoWrapper
to these values:
margin-left:-215px;
margin-top:-85px;
They need to be half the width and height of your logo.
jsfiddle
EDIT:
Also, I would suggest you put these 'reset' styles in:
html, body{
background:#F1FF29;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
精彩评论