linuxdream Posted July 5, 2009 Share Posted July 5, 2009 Sorry for the dumb question but I normally don't do CSS much. If you have div block and apply two classes to it, one containing a width and the other containing auto left and right margins, why won't it center the block? .width150{ width: 150px; } .blockCenter{ margin-left: auto; margin-right: auto; } <div class="width150 blockCenter"> content here </div> It centers the block fine when I put the width and margins in one CSS class. But shouldn't it work fine separated like the above code since the width should be seen for the margins to center properly? Any help is appreciated. Quote Link to comment Share on other sites More sharing options...
ifubad Posted July 6, 2009 Share Posted July 6, 2009 it's centering fine as is with FF2, IE6 7 & 8. What browser r u using? also, no need to use two separate declarations for the margin, just use margin: auto; /*covers both left and right*/ Quote Link to comment Share on other sites More sharing options...
linuxdream Posted July 6, 2009 Author Share Posted July 6, 2009 Ahh, thanks for the consolidation tip. I'm on FF 3.0.11 on Mac. Yea, I would think I should work fine, I'll have to debug more and see what else may be causing it. Thanks for the outside check! 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.