|
-
Oct 9th, 2004, 04:08 AM
#1
Thread Starter
Frenzied Member
CSS Position Center
How would I position a div so that its horizontical(left-right) center would be the center of the page(the center of body)? Can I somehow set it's handle to it's own center and just use: left:50%; ?
Last edited by vbNeo; Oct 9th, 2004 at 06:25 AM.
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Oct 9th, 2004, 05:12 AM
#2
There are two ways, and you need a fixed width for both. For in-flow boxes, you use margins.
Code:
#thediv {
width: 100px;
margin-left: auto;
margin-right: auto;
}
For out-of-flow boxes, you use, uh, margins 
Code:
#thediv {
position: absolute;
width: 100px;
margin-left: -50px; /* Half the negative width. */
left: 50%;
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 9th, 2004, 05:52 AM
#3
Thread Starter
Frenzied Member
Ah, nice - thanks!
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|