2011-06-29 126 views
7

由于某种原因,我无法使用IE9在我的CSS中使用rgba工作。我已经使用Chrome对其进行了测试,并且工作正常。不知道有什么问题。rgba在IE9中不工作

我的HTML是:

<!doctype html> 

<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 

     <title><?php bloginfo('name'); ?> - <?php bloginfo('description'); ?></title> 

     <link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" /> 
     <link href="http://fonts.googleapis.com/css?family=Raleway:100&v1" rel="stylesheet" type="text/css" /> 

     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
    </head> 
    <body> 
     <?php wp_nav_menu(); ?> 
    </body> 
</html> 

我的CSS是:

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} 

body { 
    font-size: 62.5%; 
} 

.menu { 
    font-size: 5em; 
    font-family: 'Raleway', arial, serif; 
} 

.menu ul li a { 
    background: rgba(0,0,0,0.5); 
    text-decoration: none; 
} 
+0

不知何故,您的网站不显示在IE9标准模式。发布到您的网站的实时链接,我将能够找到原因。 – thirtydot

回答

3

嗯,我找到了原因。似乎“兼容性视图”已启用,因此我禁用了它,并且,瞧。当我想单击刷新按钮时,我可能点击了它。

13

新标准在Internet Explorer 9的支持需要浏览器是Internet Explorer 9的标准模式(“IE9模式” )。这样做的最好方法是使用standard!DOCTYPE指令并且不使用X-UA兼容元标记或HTTP标头。调用IE9模式的!DOCTYPE如下:

<!DOCTYPE html> 

background-color: rgba(0,0,0,0.5); 
+0

好的......但不应该IE9支持简写属性上的'rgba()'呢? – BoltClock

+0

从技术上说速记应该可以工作,但它可能暴露IE CSS解析器中的错误。 – SpliFF

+0

我试过了,它仍然无法工作。 – cvandal

0

我在ie9中遇到背景颜色问题。在用google-fu浏览解决方案后,我意识到我正在使用这个破解特定div中所有CSS的border-radius.htc。不仅仅是背景颜色,还有边框和字体颜色。它被这样使用:

<style> 
     .ie-rounded-corner{behavior: url(../include/stylesheets/border-radius.htc); } 
    </style> 

    <div class="ie-rounded-corner">Hello World</div> 

我使用边界半径黑客对IE6/7/8的一些元素添加圆角。这打破了IE9的页面。删除该类后,IE9中的所有内容都按预期工作。我的圆角现在已经在ie6/7/8中消失了。传统IE浏览器现在可能需要不同的解决方案。