Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Centering A Div, placing the div to the center of a screen
oxida
post Jun 30 2008, 08:57 AM
Post #1


Member [Level 1]
****

Group: [HOSTED]
Posts: 53
Joined: 12-June 08
From: Netherlands
Member No.: 63,541



Many people would like theire website in the center of the screen.
This is how to do that.

1. make a new css document.

2. Then place the following code in it.

CODE

#main-div {
position: absolute;
top: 50%;
left: 50%;
width: 70em;
height: 50em;
margin-top: -25em; /*always take 1/2 from the size of the height, they have to be negative*/;
margin-left: -35em; /*always take 1/2 from the size of the width, they have to be negative*/
}


Then place in your html: the following code.

CODE
<div id="main-div">
content
</div>


This wil place the div box in the center of the screen, works mostly for any resolution depends on the size of your div box.

Hope this helped some people.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Take A Screen Shot Of Your Desktop.(22)
  2. Hide Names In Welcome Screen(0)
  3. A Tutorial On How To Change Your Window's Screen Name's Icon(0)
  4. Dynamic Signatures - The Real Way To Go(8)
  5. Css Centering(1)


 



- Lo-Fi Version Time is now: 7th October 2008 - 01:44 AM