代码之家  ›  专栏  ›  技术社区  ›  Rachel

如何解决IE不同版本之间的css不兼容/差异?

  •  1
  • Rachel  · 技术社区  · 14 年前

    我遇到了一个问题,我的web应用程序在 (IE5 & IE6) 与…相比 (IE7 & IE8)

    CSS 问题,但我不想陷入这样一种情况,我做了一些改变 CSS File 而不是在 (IE7和IE8)

    How should I approach problem to resolve CSS incompatibities or differences between different version of IE ?

    2 回复  |  直到 14 年前
        1
  •  0
  •   JohnB    14 年前

    创建样式表的级联,如下所示:

    <link id="stylesheet1" rel="stylesheet" href="css/style.css" type="text/css" media="all" /
    <!--[if IE]>
      <link id="stylesheet2" rel="stylesheet" href="css/ie.css" type="text/css" media="all" />
    <![endif]-->
    <!--[if lte IE 6]>
      <link id="stylesheet3" rel="stylesheet" href="css/ie6.css" type="text/css" media="all" />
    <![endif]-->
    <!--[if lte IE 5]>
      <link id="stylesheet4" rel="stylesheet" href="css/ie5.css" type="text/css" media="all" />
    <![endif]-->
    

    样式表:

    .myclass{
      width:100px;
    }
    

    ie.css文件:

    /* override class from style.css */
    .myclass{
      width:105px;
    }
    

    /* override class again from ie.css */
    .myclass{
      width:110px;
    }
    

    ie5.css格式:

    /* if necessary, override class again from ie6.css */
    .myclass{
      width:115px;
    }
    

    Pekka是对的,您需要根据具体情况来考虑每个问题/错误/显示差异。因此,如果IE6中没有正确显示某些内容,则需要在中进行调整 ie6.css . 即使在那之后,它也没有在IE5中显示出来,你需要在IE5中调整它 ie5.css .


    说明:

    <!--[if IE]>
      only Internet Explorer browsers (all versions) will see HTML between these statements
    <![endif]-->
    <!--[if lte IE 6]>
      only Internet Explorer 6 or lower browsers will see HTML between these statements
    <![endif]-->
    <!--[if lte IE 5]>
      only Internet Explorer 5 or lower browsers will see HTML between these statements
    <![endif]-->
    
        2
  •  0
  •   Adam    14 年前