RockyLou Posted April 28, 2007 Share Posted April 28, 2007 I'm trying to position a div on the page absolutely. I got it to work pretty much except now I'm trying to center the div on the page. Here's my code so far (the other part is in css): #DivHeader { border: 1px solid #000099; background-color: $color1; padding: 4px; color: white; } <div id=DivHeader align=center style="position: absolute; top: 0px;"> I don't want to specify how far from the left or right, I just want it centered. Any ideas? Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 28, 2007 Share Posted April 28, 2007 margin:auto; ... forget absolute positioning, it tends to be problematic in all but the most trivial layout. And 999 times out of 1000 you don't need it if you understand floats. Quote Link to comment Share on other sites More sharing options...
RockyLou Posted April 29, 2007 Author Share Posted April 29, 2007 margin: auto? Well in my case I have to use absolute positioning the way I am running my scripts. Quote Link to comment Share on other sites More sharing options...
rh-penguin Posted April 29, 2007 Share Posted April 29, 2007 #DivHeader { border: 1px solid #000099; background-color: $color1; padding: 4px; color: white; margin:auto; } <div id=DivHeader align=center style="position: absolute; top: 0px;"> Quote Link to comment Share on other sites More sharing options...
RockyLou Posted May 9, 2007 Author Share Posted May 9, 2007 Thanks; it works now. Quote Link to comment Share on other sites More sharing options...
emehrkay Posted May 9, 2007 Share Posted May 9, 2007 myspace layout? its a hack but position: absolute; width: 400px; margin: 0 auto; padding-left: - 200px; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.