/ Published in: CSS
Expand |
Embed | Plain Text
#mydiv { position:absolute; top: 50%; left: 50%; width:350px; height:300px; margin-top: -150px; /*set to a negative number 1/2 of your height*/ margin-left: -175px; /*set to a negative number 1/2 of your width*/ border: 2px solid #2982C6; background-color: #FFF; text-align: center; }
Comments
Subscribe to comments
You need to login to post a comment.

Excellent snipplet, works great if you need to center a non-expanding div like a login form.
Brilliant, a very late comment, but worked for me - so I thought I'd say my thanks :') - Jak Clark www.jakclarkdesign.co.uk