Be a Supporter!

Div Layer Blues

  • 555 Views
  • 2 Replies
New Topic Respond to this Topic
JimmyDallas
JimmyDallas
  • Member since: May. 17, 2003
  • Offline.
Forum Stats
Member
Level 31
Gamer
Div Layer Blues 2006-11-14 22:21:39 Reply

ok, for the longest, i been trying to figure out how to make a div layer center properly.
the short question: is there a certain setting in the CSS to make it all "perfect" (so to say)?


[PHP: Main]-[AVGN Club]
"You know a dame is classy when she got some jiggle in her assy." - Unknown

BBS Signature
Bizarro
Bizarro
  • Member since: Dec. 6, 2002
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to Div Layer Blues 2006-11-14 23:52:34 Reply

there are 2 ways of doing this nicely and I happened to have stumbled upon a website explaining both the other day
one way is negative margins in which you have the give the div, position:absolute a left value of 50% and a margin-left that is negative half of the divs width.
example
the other method, which I prefer, is whatever contains the div (in most cases the body)that you want to be centered has to have text-align:center, and then the div you want centered has to have a right and left margin of auto and text-align:left to reset the alignment of the text(the text-align crap is only needed for IE5 so if you dont care about them you can leave it out)
example


BBS Signature
Jessii
Jessii
  • Member since: Feb. 10, 2005
  • Offline.
Forum Stats
Member
Level 36
Movie Buff
Response to Div Layer Blues 2006-11-15 07:41:52 Reply

What I do is set

body {width:780px;}

Then I have my divs float and have my margins set so that they control where the page ends up. So say you have a top div that's 780px; wide, then you'll have the divs underneath lined up using your top div as a guide. You can take alook at my css if you want an example: http://www.fauxdreams.net/main.css