fanfavorite Posted January 8, 2008 Share Posted January 8, 2008 What I am trying to do is set a div outside of all other divs that will always be just right of my page. I don't want it to effect anything on the page, so I am using absolute positioning. This works in IE7, but not in Firefox or Safari so far. Firefox and Safari ignore the margin auto and just place the div left:0px. Any ideas how to make sure that these browsers center it? #sitetype { position:absolute; margin:0px auto; top: 34px; width:831px; text-align:right; } Thanks. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 8, 2008 Share Posted January 8, 2008 javascript or use percentages instead of fixed height/width Quote Link to comment Share on other sites More sharing options...
duclet Posted January 9, 2008 Share Posted January 9, 2008 Please post a link to your site. Quote Link to comment Share on other sites More sharing options...
bronzemonkey Posted January 9, 2008 Share Posted January 9, 2008 Make sure you've used {position:relative;} on the element that you're looking to position relative to. The fact that {margin:0 auto;} is working in IE7 must be down to a bug in that browser. Since you're using a fixed width you should be able to "center" the div like this: #sitetype { position:absolute; top: 34px; left:50%; /*will position the left corner of the div at the mid-point of the div it is being positioned relative to*/ width:831px; margin-left:-415px; /*will pull your div half its own width back towards the left*/ Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted January 9, 2008 Author Share Posted January 9, 2008 Thanks all. That code is perfect bronze! 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.