Tag cloud
See my latest projects
About this site
This site is proudly powered by WordPress. If you like what you see, why not subscribe?
Copyright © 2008 Aaron Russell. All rights reserved.
Monday, 27 October 2008
The CSS display property can be the bane of the web designer’s life as support varies from browser to browser, making it all a bit more complicated than it should be. In this article I will show a quick and simple way to get the display:inline-block declaration rendering consistently across all major browsers.
Quirksmode offers a very useful summary of browser support for the display property. As you’d expect, Internet Explorer is the main cause of problems as support for the inline-block value is ‘incomplete’ (read ‘flakey’). Surprisingly, Firefox 2 also causes unexpected problems as the value is not supported at all.
I know most Firefox users actively upgrade and so started using Firefox 3 long ago (which supports inline-block with no issues at all). However, that’s what makes this little problem all the more difficult to spot as chances are you don’t have Firefox 2 lying around for testing any more?
Whilst Firefox 2 doesn’t support inline-block, what it does support is the Mozilla specific -moz-inline-box value - which to you and me and all our end users is exactly the same. So this is easy to fix.
#mydiv .myclass { display: -moz-inline-box; display: inline-block; }
Back to our friend Internet Explorer and we need to add another couple of lines to our CSS to get this working in both IE6 and IE7. By combining a couple of IE version-specific filters with a display:inline declaration after we have made our display:inline-block declaration, Internet Explorer starts behaving itself.
* html .myclass { display:inline; } /* for IE 6 */ * + html .myclass { display:inline; } /* for IE 7 */
Honestly, I have know idea why this works. I’m sure some greater CSS brains than mine out there know exactly what is going on, but for me this doesn’t make sense and is confusing. But… it works, which is good enough.
So when we round all this together we have a snippet of CSS that should look vaguely like this:
.myclass { display: -moz-inline-box; display: inline-block; } * html .myclass { display:inline; } /* for IE 6 */ * + html .myclass { display:inline; } /* for IE 7 */
And there we have it - cross browser support for display:inline-block. Hopefully this tip will save you countless hours of hair-pulling frustration.
Are you having trouble with your excerpts? Is WordPress misbehaving and making your them look below standard when all you want to do is use it’s native excerpt function? You’re not alone so read on.
Every once in a while I come across something that just makes me smile. Today it comes in the form of an advertisement for the German energy firm, Epuron. Watch it here.
SEO consultant Eggman John recently posted an article outlining seven reasons why you don’t need SEO. John’s article caused a stir amongst the SEO community, but read why I think there is a lot of sense in what he says.
When flicking through my feeds I came across this clever little poster campaign by Russian Bear Vodka, explaining why real men don’t drink and drive in a subtly clever way.
The CSS ‘display’ property is definitely a bit more complicated than it should be. In this article I will show a quick and simple way to get the display:inline-block declaration rendering consistently across all major browsers.
“RT @The_Dude_Blog : LMAO - check mout this stop frame video - its awesome and the best 30 secs i've had all day! http://tinyurl.com/2vw64t”
Posted about 8 hours ago.
This site is proudly powered by WordPress. If you like what you see, why not subscribe?
Copyright © 2008 Aaron Russell. All rights reserved.