在 IE 中修复 CSS <!--[if lt IE 8]>

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3958913/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 22:59:40  来源:igfitidea点击:

FIX CSS <!--[if lt IE 8]> in IE

cssinternet-explorerinternet-explorer-8

提问by meotimdihia

How can I use this:

我该如何使用它:

    <!--[if lt IE 8]>
    <style type='text/css'>
  #header ul#h-menu li a{font-weight:normal!important}
    </style>
    <![endif]-->
    <!--[if lt IE 8]>
    <style type='text/css'>
  #header ul#h-menu li a{font-weight:normal!important}
    </style>
    <![endif]-->

If I remove <!--[if lt IE 8]><![endif]-->, above code'll run good in IE 8, but if I don't do it, it wont run. Help me with fixed IE, so that I can use above code in all IE versions.

如果我删除<!--[if lt IE 8]><![endif]-->,上面的代码将在 IE 8 中运行良好,但如果我不这样做,它将无法运行。帮助我修复 IE,以便我可以在所有 IE 版本中使用上述代码。

I want the code #header ul#h-menu li a{font-weight:normal!important}to run only in IE.

我希望代码#header ul#h-menu li a{font-weight:normal!important}只能在 IE 中运行。

回答by Pekka

If you want this to work in IE 8 and below, use

如果您希望它在 IE 8 及以下版本中工作,请使用

<!--[if lte IE 8]>

ltemeaning "Less than or equal".

lte意思是“小于或等于”。

For more on conditional comments, see e.g. the quirksmode.org page.

有关条件注释的更多信息,请参见quirksmode.org 页面

回答by Rocket Ronnie

<!--[if lt IE 8]><![endif]-->

The lt in the above statement means less than, so 'if less than IE 8'.

上面语句中的 lt 表示小于,所以“如果小于 IE 8”。

For all versions of IE you can just use

对于所有版本的 IE,您都可以使用

<!--[if IE]><![endif]-->

or for all versions above ie 6 for example.

或者对于以上所有版本,例如 6。

<!--[if gt IE 6]><![endif]-->

Where gt is 'greater than'

其中 gt 是“大于”

If you would like to write specific styles for versions below and including IE8 you can write

如果您想为以下版本(包括 IE8)编写特定样式,您可以编写

<!--[if lte IE 8]><![endif]-->

where lte is 'less than and equal' to

其中 lte 是“小于等于”

回答by oezi

[if lt IE 8]means "if lower than IE8" - and thats why it isn't working in IE8.

[if lt IE 8]意思是“如果低于 IE8”——这就是它在 IE8 中不起作用的原因。

wahat you want is [if lte IE 8]which means "if lower than or equal IE8".

你想要的是[if lte IE 8]这意味着“如果低于或等于 IE8”。

回答by embocs

Use <!-- [if lt IE 9] >exact this code for IE9.The spaces are very Important.

<!-- [if lt IE 9] >对 IE9使用此代码。空格非常重要。

回答by Boldewyn

How about

怎么样

<!--[if IE]>
...
<![endif]-->

You can read hereabout conditional comments.

您可以在此处阅读有关条件注释的信息。

回答by Bobby Hyman

    <!--[if IE]>
    <style type='text/css'>
    #header ul#h-menu li a{font-weight:normal!important}
    </style>
    <![endif]-->

will apply that style in all versions of IE.

将在所有版本的 IE 中应用该样式。

回答by Lucia

Also, the comment tag

还有评论标签

<comment></comment> 

is only supported in IE 8 and below, so if that's exactly what you're trying to target, you could wrap them in comment tag. They're the same as

仅在 IE 8 及更低版本中受支持,因此如果这正是您要定位的目标,您可以将它们包装在评论标签中。他们和

<!--[if lte IE 8]><![endif]-->

In which lte means "less than or equal to".

其中 lte 的意思是“小于或等于”。

See: Conditional Comments.

请参阅:条件注释

回答by Timothy

I found cascading it works great for multibrowser detection.

This code was used to change a fade to show/hide in ie 8 7 6.

此代码用于更改淡入淡出以显示/隐藏即 8 7 6。

$(document).ready(function(){
    if(jQuery.browser.msie && jQuery.browser.version.substring(0, 1) == 8.0)
         { 
             $(".glow").hide();
            $('#shop').hover(function() {
        $(".glow").show();
    }, function() {
        $(".glow").hide();
    });
         }
         else
         { if(jQuery.browser.msie && jQuery.browser.version.substring(0, 1) == 7.0)
         { 
             $(".glow").hide();
            $('#shop').hover(function() {
        $(".glow").show();
    }, function() {
        $(".glow").hide();
    });
         }
         else
         {if(jQuery.browser.msie && jQuery.browser.version.substring(0, 1) == 6.0)
         { 
             $(".glow").hide();
            $('#shop').hover(function() {
        $(".glow").show();
    }, function() {
        $(".glow").hide();
    });
         }
         else
         { $('#shop').hover(function() {
        $(".glow").stop(true).fadeTo("400ms", 1);
    }, function() {
        $(".glow").stop(true).fadeTo("400ms", 0.2);});
         }
         }
         }
       });