4

Anyone know any tricks to use the CSS :not() selector in IE and Chrome?

e.g. this works in Firefox: iframe:not(.anifrmclass){}

Cheers!

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
phillyville
  • 305
  • 1
  • 6
  • 14

1 Answers1

9

Specificity is your friend. Apply your :not(.anifrmclass) styles to all <iframe>s then override with other values for <iframe class="anifrmclass">.

iframe {
    /* Styles for all -other- iframes */
    display: none;
}

iframe.anifrmclass {
    /* Override for this class with values other than the above */
    display: inline-block;
}
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
  • Why didn't I think of that. Thanks, BoltClock! – phillyville Dec 16 '10 at 19:02
  • When styling list items with something like margin, li:not(:last-child) does not work, and this method is no help. No one wants to add a special class to the end list item. – iamface Feb 23 '13 at 04:04