Possible Duplicate:
What does a star-preceded property mean in CSS?
I came across this while browsing for cross-browser support for display: inline-block...
selector {
display: -moz-inline-box;
display: inline-block;
zoom: 1;
*display: inline;
}
What does *display do?
Link from: http://www.aarongloege.com/blog/web-development/css/cross-browser-inline-block/
*property: value;
This is a hack, so I don't recommend that you use it. Styles represented like this are interpreted only by IE 7 and below, so other browsers ignore those styles completely.
It's non-standard (or valid) CSS, but it's sometimes used to beat IE into submission.
as other have said this is a hack for IE7 and below
BUT this one, the example you've given is a specific hack so unlike a comment you've received I wouldn't recommend removing it yet.. you can move it or remove it after you read this and don't need it ;)
btw I agree -moz-inline-box is probably no longer necessary, it was for older versions of Firefox
selector {
display: -moz-inline-box;
display: inline-block;
zoom: 1;
*display: inline;
}
Is a specific hack to get IE6/7 to display a block level element as an inline-block. Although IE has supported inline-block
since v5.5 it didn't do so natively on block-level elements
So in this case what you need to do is give the element "layout" (zoom: 1;
) and feed it display: inline
after that.
Now display:inline-block
also gives an element layout so if you remove the display-inline
rule to a separate ruleset (either in a conditional or a hacked rule) you no longer have to use zoom: 1;
My preferred hack for this (for demonstration purposes) & because inline-blocks are so dashed useful, & because it's shorter is
selector {
display: inline-block;
}
selector {
display: inline !ie7;
}
that !ie7
is doing the same as the *
before the display property, it's feeding that rule to IE7 and below - you could use the *
version in the second rule too, however the !ie7 makes it clear, to me anyway it's a hack, and who it's for.
If you have a specific, conditional style sheet for IE7 and below you can simply put the second rule in it - without any *
or ie7
;)
selector {
display: inline;
}
because IE will still read the first ruleset and get it's hasLayout triggered to true
by the inline-block
in there, you don't need zoom
the quoted hack you mention is popular because it keeps all the parts in the one ruleset, but zoom:1
is needed in that case as inline-block
won't work to set hasLayout if it's in the same ruleset as the other display
property
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With