문제

I'm using conditional statements to load css for a specific version of IE or any other browser.

For example, let's say I'm targeting IE7.

So I'll use this:

    <!--[if IE 7]>
        <link rel="stylesheet" href="/style/ie7.css" />
    <![endif]-->

Now... this works when I'm using IE7 but I wanted that to also work for any other browser. When I check on firebug, this css is not loaded.

How can I make it work for IE7 and any other browser?

Thanks!

도움이 되었습니까?

해결책

You could do this:

<!--[if IE 7]><!-->
    <link rel="stylesheet" href="/style/ie7.css" />
<!--<![endif]-->

Notice how the syntax highlighting changes because the link element is no longer commented out by the conditional statements.

The only caveat is that IE10 and later will also use this stylesheet, because IE10 and later now ignore HTML conditional statements entirely by design. Since IE10 is pretty well-regarded in terms of standards compliance, this should not be a problem, but if you don't want any version of IE except 7 to use this stylesheet, I don't think there's a workaround for it that doesn't involve JavaScript.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top