HTML CSS examples for CSS Layout:Div Align
Center a DIV along the top
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> body {<!-- www .j ava 2s .co m--> background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png'); background-repeat:repeat-x; margin:0px; } .mainhome { width:856px; margin-top:0; margin-right:auto; margin-bottom:0; margin-left:auto; } .header { height:237px; background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png'); background-repeat:repeat-x; clear:left; } .mainimage { width:856px; height:424px; background-color:Chartreuse; position:absolute; top:221px; clear:left; z-index:-2; } </style> </head> <body> <div class="mainhome"> <div class="header"></div> <div class="mainimage"></div> </div> </body> </html>