How to make a DIV absolute center in Browser display area.

Here is the Code . Copy this and paste it in the HTML editor and see the preview in browser

<div style="width:400px;height:200px;position:absolute;top:50%;left:50%;margin-left:-200px;margin-top:-100px;background:#e5e5e5;border:5px solid #999999;z-index:999;-moz-box-shadow:0 5px 5px #000000;-webkit-box-shadow:0 5px 5px #000000;-moz-border-radius:20px;-webkit-border-radius:20px;"> <h2 style="margin:20px;">This will be perfectly Center aligned. Now resize th browser window and see that the DIV will be dynamically centered.
</div>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.