css - 表格单元格 div 的透明度

标签 css internet-explorer

我的标记如下。 #template 元素的 background 属性设置为 rgba,具有一定的透明度。在 IE9 中,透明度似乎不起作用。如果我从 #template 样式中删除 display: table-cell,则透明度有效,但单元格不再是 100% 高。这仅在 IE 中。它适用于 Chrome。没有尝试使用 FF。

我正在寻求帮助,以了解发生这种情况的原因以及解决方法。

我知道如果我删除 display: table-... 样式,它会起作用,但我的布局需要这些样式。除了display: table-cell 用于#template,我原来没有,但发现没有它,IE9 不会使它100% 高。我需要它 100% 高。

http://jsfiddle.net/d6nUN/

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      html, body {
        height: 100%;
      }
      #container {
        display: table;
        height: 100%;
        width: 100%;
      }
      #container #content {
        background-color: #ff6622;
        display: table-row;
        height: 100%;
      }
      #template {
        background: rgba(255, 255, 255, 0.3);
        display: table-cell;
        height: 100%;
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="container">
      <div id="content">
        <div id="template">text</div>
      </div>
    </div>
  </body>
</html>

最佳答案

尝试以这种方式拉伸(stretch)#template:

#template {
    ...
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
}

http://jsfiddle.net/pfUe7/2/

关于css - 表格单元格 div 的透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15951038/

相关文章:

java - 使用 Selenium Web 驱动程序无法在 IE 中打开任何网页

css - 设置 Angular Material Slider 的样式,使其更厚/更高

jquery - 如何为选项卡菜单中的当前元素添加阴影?

jquery - css content 属性可以与输入值选择器一起使用吗

css - IE9 fieldset圆 Angular

angularjs - IE10 上未定义“Angular ”

javascript - 创建全局变量并生成随机数并在 Javascript 中调用函数时更新变量

CSS float 逻辑(内部文本未移动)

html - 如何在 IE7 中将绝对定位的 div 居中?

javascript - 部署后 IE 9 中的 Telerik MVC DatePicker + OnChange 事件问题