Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html IE浏览器检查中的条件语句_Html_Css_Browser_Conditional Comments - Fatal编程技术网

Html IE浏览器检查中的条件语句

Html IE浏览器检查中的条件语句,html,css,browser,conditional-comments,Html,Css,Browser,Conditional Comments,我有以下代码来显示IE7中的某个UL。然后,我如何将其他UL样式应用于除IE7之外的所有浏览器?例如chrome、firefox和IE8-IE10 <!--[if IE 7]> <ul class="toggle" style="margin-right:30px; list-style:none"> @if (Model.CourseSections != null) { foreach (

我有以下代码来显示IE7中的某个UL。然后,我如何将其他UL样式应用于除IE7之外的所有浏览器?例如chrome、firefox和IE8-IE10

<!--[if IE 7]>
        <ul class="toggle" style="margin-right:30px; list-style:none">
          @if (Model.CourseSections != null)
          {
            foreach (var sectionItem in Model.CourseSections)
            {                     
              <li>
                <h5 class="accordion-title">@sectionItem.Title<span class="accordion-icon"></span></h5>
                <div class="accordion-content">
                  <ul>
                    @foreach (var subSectionItem in sectionItem.SectionContents)
                    {
                      <li><a href="#" id="menuItem @subSectionItem.ContentID @sectionItem.CourseSectionID" onclick="SubItemMenu(id)">@subSectionItem.Content.Name</a></li> 
                    }
                  </ul>
                </div>
              </li>
            }
          }
        </ul>
        <![endif]-->

        <ul class="toggle" style="list-style:none">
          @if (Model.CourseSections != null)
          {
            foreach (var sectionItem in Model.CourseSections)
            {                     
              <li>
                <h5 class="accordion-title">@sectionItem.Title<span class="accordion-icon"></span></h5>
                <div class="accordion-content">
                  <ul>
                  @foreach (var subSectionItem in sectionItem.SectionContents)
                  {
                    <li><a href="#" id="menuItem @subSectionItem.ContentID @sectionItem.CourseSectionID" onclick="SubItemMenu(id)">@subSectionItem.Content.Name</a></li> 
                  }
                  </ul>
                </div>
              </li>
            }
          }
        </ul>

    @if(Model.CourseSections!=null) { foreach(Model.CourseSections中的var sectionItem) {
  • @章节项目.标题
      @foreach(sectionItem.SectionContents中的var subSectionItem) {
    • }
  • } }

您应该能够执行以下操作:

<!--[if IE 7]>
   You're using IE!
<![endif]-->
<!--[if !IE 7]>
   You're using something else!
<![endif]-->

IE条件注释的文档可在此处找到:


正如@spudley在评论中所说的,如果唯一的区别是
ul
中的
样式,那么这不是适合您的最佳解决方案。

您应该能够做到以下几点:

<!--[if IE 7]>
   You're using IE!
<![endif]-->
<!--[if !IE 7]>
   You're using something else!
<![endif]-->

IE条件注释的文档可在此处找到:


正如@spudley在评论中所说的,如果唯一的区别是
ul
中的
样式,那么这不是最好的解决方案。

不同浏览器的不同标记是可怕的。如果需要条件样式,请选择(而不是开头的
):

(HTML5Boilerplate一直在使用类似的东西,但它们最近才开始使用。)


当然,如果您真的需要浏览器条件标记(不仅仅是样式),这并不能节省您的时间,但我要说的是,您的实际问题是“如何在不使用浏览器条件标记的情况下执行X”。

不同浏览器的不同标记非常糟糕。如果需要条件样式,请选择(而不是开头的
):

(HTML5Boilerplate一直在使用类似的东西,但它们最近才开始使用。)


当然,如果您真的需要浏览器条件标记(不仅仅是样式),这并不能节省您的时间,但我要说的是,您的实际问题是“如何在不使用浏览器条件标记的情况下执行X”.

如果差异只是在样式上,您可以使用页面开头的条件注释在实际html元素上设置一个类。()


如果差异只是在样式上,那么可以使用页面开头的条件注释在实际html元素上设置一个类。()


这两段代码之间有什么区别?如果它只是
元素上的样式,那么您应该找到不同的解决方案;你可以发送相同的HTML,但是如果你真的需要的话,只需要一个条件样式表就可以了。这两段代码之间有什么区别?如果它只是
元素上的样式,那么您应该找到不同的解决方案;您可以发送相同的HTML,但如果确实需要,只需为其提供一个条件样式表。请注意,虽然语法在IE中起作用,但它是无效的-请参阅答案中给出的链接和注释,以了解将要验证的语法。请注意,虽然语法在IE中起作用,这是无效的-请参考答案中给出的链接和注释,以了解将要验证的语法。
something {
    // styling for all browsers
}

.lt-ie9 something { 
    // styling for IE8 and below
}
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class=""> <!--<![endif]-->
<head>...
.toggle {list-style:none}
.lt-ie8 .toggle {margin-right:30px;}