Wednesday, March 12, 2014

Vertical and Horizontal Center With HTML5 and CSS3

HTML:

<!doctype html>
<html>
            <head>
                        <meta charset="utf-8">
                        <link rel="stylesheet" type="text/css" href="css/xit.css" />
                        <link rel="shortcut icon" href="images/xitlogosmall.ico" />
                        <title>xit solutions</title>
            </head>
            <body>
                        <div class="LogoContainer"><a class="logo" href="#"></a> </div>
            </body>
</html>
 
CSS:
@charset "utf-8";
/* CSS Document */


*
{
     margin:0;padding:0; 
}


html,body
{
     height:100%;  
}


body
{
     display: table;
     margin: 0 auto;
     background-color:#9ec126;
     color: #fff;
     line-height: 1.5em;
     font-family: Arial;
     font-size: 11px;
}


.LogoContainer
{
     height: 100%;
     display: table-cell; 
     vertical-align: middle;   

     /*border:#F30 solid thin;*/
     text-align:center;

}

.LogoContainer a
{
     outline: 0;
     text-decoration: none;
}


a.logo
{
     display: block;
     background: url(../images/XITLogo.png) no-repeat ;
     width: 216px;
     height: 58px;
}


Links:
jsfiddle
stackoverflow

No comments: