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. Link to comment https://forums.phpfreaks.com/topic/85032-solved-absolute-position-with-auto-margins/ 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 Link to comment https://forums.phpfreaks.com/topic/85032-solved-absolute-position-with-auto-margins/#findComment-434014 Share on other sites More sharing options...
duclet Posted January 9, 2008 Share Posted January 9, 2008 Please post a link to your site. Link to comment https://forums.phpfreaks.com/topic/85032-solved-absolute-position-with-auto-margins/#findComment-434646 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*/ Link to comment https://forums.phpfreaks.com/topic/85032-solved-absolute-position-with-auto-margins/#findComment-434699 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! Link to comment https://forums.phpfreaks.com/topic/85032-solved-absolute-position-with-auto-margins/#findComment-434829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.