newbornultra Posted November 30, 2012 Share Posted November 30, 2012 Hi, I have to center a div in an absolute parent div. The usual suspect giving a width and adding margin:0 auto doesn't work. It "sorta" works if I put left:25% in the div I'm trying to center, but it doesn't adjust if I resize the screen. How do I do this? <div id="rest"> <div class="wrap-reset"> some content in center.. </div> </div> .wrap-reset { width:960px; position:relative; margin:0px; } #rest { position:absolute; top:0px; } Thanks, Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted November 30, 2012 Share Posted November 30, 2012 Firstly I'd always style elements in the order the are set in html. So for instance, put your #rest css code above the .wrap_reset class declaration. About your question, not too sure with absolute positioning but came across this example: http://jsfiddle.net/brettdewoody/C4jSS/ Hope it helps. Regards, AoTB. Quote Link to comment Share on other sites More sharing options...
codefossa Posted November 30, 2012 Share Posted November 30, 2012 margin: 0 auto; 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.