简体   繁体   中英

Target IE7/IE8 in css (less)

I'm using .less to compile CSS.

Is there a way to target IE7/IE8 in the less file for particular rules?

Thanks

Absolutely use the conditional classes that Paul Irish posted about if you can, because it's slick, easy to write and maintain styles for, and limits your hackery to one place.

That said, if you really just want to target one rule at some version of old IE, you can use your favorite hacks by letting the LESS compiler know that whatever you're trying is well outside the bounds of things it should worry about :)

The following will generate all kinds of LESS compiler errors:

.class{
        _margin: !15pl*madhax!__dang,IE;
}

But, if you wrap your hacky madness inside ~"" , then less will ignore it (although you still have access to @variables if you want to use them)

.class{
        _margin: ~"!15pl*madhax!__dang,IE";
}

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM