A common way to display a separator in the middle of a page is to display it as a table with a table cell:
<body> <div id="wrapper"> <div id="inner"> </div> </div> </body>
html, body { margin:0; height:100%; } body { display:table; width:100%; } #wrapper { display:table-cell; vertical-align:middle; height:100%; width:100%; } #inner { height:50%; width:50%; margin:0 auto; }
JSFiddle example .
In this example, #inner is 50% of the width and height of #wrapper , which is 100% of the width and height of the page body.
Since #wrapper displayed as a table-cell inside the body displayed as table , the contents inside will depend on the vertical-align:middle property, with the result that the #inner is in the vertical middle of the page.
Application margin:0 auto; to the divider #inner then aligns it horizontally.
The beauty is that you donβt have to worry about shifting the #inner divisor and not just go for the percentage width. The fixed width will still be aligned in the middle of the containing #wrapper .
This is supported in all modern browsers: http://caniuse.com/#feat=css-table
source share