TheFilmGod Posted February 2, 2009 Share Posted February 2, 2009 How can I center an li or div without a specified width? I can do display: inline-block; or display: table; FF2 doesn't support inline-block; so I don't mind using display: table. IE7 doesn't support either. Is there a way to simulate the display: table; effect in IE7 without adding extra markup? Quote Link to comment Share on other sites More sharing options...
Madatan Posted February 3, 2009 Share Posted February 3, 2009 Cant you use margin: 0 auto; ? Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted February 4, 2009 Author Share Posted February 4, 2009 Cant you use margin: 0 auto; ? To center something with margin: 0 auto; the element must be a displayed as a bock and have a fixed width. Quote Link to comment Share on other sites More sharing options...
haku Posted February 4, 2009 Share Posted February 4, 2009 If the element isn't block, then you can't center stuff inside it, only it inside its containing element. Which means that the only way it could be done is to use text-align: center on the containing element. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted February 5, 2009 Author Share Posted February 5, 2009 display: table; or display: inline-block; are viable solutions for FF users. IE doesn't support table. It will not display divs, li, or other block level elements with display: inline-block. Only elemnts that were initially inline, can inherit the inline-block property. Quote Link to comment Share on other sites More sharing options...
haku Posted February 5, 2009 Share Posted February 5, 2009 Seeing as they are FF only solutions, they are pretty much non-solutions, unless an equivalent hack can be found for IE. Let me know if you find one, I'm interested for sure. 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.