CSS3的浏览器兼容性问题

One*_*ror 1 html javascript jquery css3

我使用一些CSS3设计了一些网页.它在Google Chrome中看起来不错,但在Internet Explorer中样式变得笨拙.我有两个问题:


我可以这样做:我可以制作两个样式表,并根据用户的浏览器加载适当的版本.让我说清楚一下:

if browser is Internet Explorer
    use stylesheet1.css
else
    use stylesheet2.css
Run Code Online (Sandbox Code Playgroud)

我的主要问题是border-radius财产的使用.有没有办法直接避免这种情况.

nic*_*har 6

在HTML /标题中,执行以下操作:

<!--[if IE]>
 <link rel = "stylesheet" type = "text/css" href = "ie-css.css" />
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

您还可以进一步细分:

<!--[if IE 7 ]>     
 <link rel = "stylesheet" type = "text/css" href = "ie7-css.css" />
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

或许多其他组合:

<!--[if IE 7 ]>
<!--[if lt IE 7]>     <--- less than IE7
<!--[if gt IE 7]>     <--- greater than IE7
<!--[if IE 8 ]>
<!--[if IE 9 ]>
<!--[if !IE]> 
Run Code Online (Sandbox Code Playgroud)

HTML5 Boilerplate的建议(以及使用的条件):

<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)

  • 只需像平常一样添加适用于chrome和FF的css,只有在用户使用IE时,才会包含来自@nickhar的代码 (2认同)