I want to make my div be positioned in the middle-center part of the web page. I'm attempting to make a pre-loader div which should be in the middle-center part of the web page and after the page loads, that div will be hidden. How can I achieve such?
The div should be centered horizontally and vertically.
<div class = 'middle'></div>
.middle{
margin: auto;
width: 900px;
}
to center a div both hor and ver you could do this way:
markup
<div class="centered"></div>
css
.centered{
position:absolute;
width:100px;
height:100px;
left:50%;
top:50%;
margin-left:-50px;
margin-top:-50px;
}
fiddle: http://jsfiddle.net/steweb/qSvAQ/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With