首页 文章

CSS片段将在旧浏览器中显示蓝色段落,在较新的浏览器中显示红色,在IE6中显示绿色,在IE7中显示黑色

提问于
浏览
-2

有没有办法写一个CSS片段,在旧版浏览器中显示蓝色的段落,在较新的浏览器中显示红色,在IE6中显示绿色,在IE7中显示黑色 .

从我这边我做了这个剪断,但不确定它会工作,是否有人知道另一个片段使其工作 .

#content p{color:blue}
html>body #content p {color:red}
* html #content p{color:green}
html>body #content p {*color:black;}

2 回答

  • 0

    这可能有所帮助 -

    html body #content p {
           color: red; /* all browsers including Mac IE */
           *color: black; /* IE 7 and below */
           _color/**/: blue; /* IE 5.0 */
           _color:/**/ blue; /* IE 5.5 only */
           _color/**/:/**/ green; /* IE 6 only */
        }
    
  • 0

    这是一段可怕的记忆之旅:

    * p { color/**/:blue; } /*IE5*/
    
    * html p { color: green; } /*IE6*/
    
    *:first-child+html p { color: black; } /*IE7*/
    
    p { color: red; } /*The rest*/
    

    幸运的是,'s a reference I'多年来没有提及:https://css-tricks.com/snippets/css/browser-specific-hacks/

    如果你必须以任何方式支持IE 5,你会有最深切的同情 .

相关问题