Prev | Current Page 244 | Next

Charles Wyke-Smith

"Stylin' with CSS: A Designer's Guide 2nd Edition"


The Backslash-Comment Hack
If you write a comment with a backslash right before the closing *, highlighted
in this line of code,
/* this a comment \*/
then Internet Explorer for Mac does not think the comment has ended and
ignores all the CSS that follows until it encounters a comment that is closed
in a normal way. (If you like to add comments after, or on the same line as,
your selectors, don??™t do it here, since the positioning of the comments is what
makes this hack work.)
For example,
/* a hack for IE Win only \*/
* html div#listcontainer ul {border-top:2px solid #069;}
/*end of hack */
Here, Internet Explorer for Mac ignores the line with the * html selector,
even though it is perfectly capable of reading it; it thinks the ?¬? rst comment
doesn??™t close until the end of the second one, so the * html selector is
hidden from it. The combination of the star and backslash hacks gives you
a rule that is only read by Internet Explorer 6 for Windows. However, with
Internet Explorer for Mac now almost obsolete, I tend to use the star hack
without wrapping it in the backslash hack. It??™s your choice.
DESIGNING INTERFACE COMPONENTS 217
I??™ve included a couple of variations of styling for this menu in the
download for this chapter on www.stylinwithcss.com.
Now let??™s take what we have learned about lists to the next level and
create a multi-level menu.


Pages:
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256