【问题标题】:What is the solution for opacity inconsistency in IE9IE9不透明度不一致的解决方法是什么
【发布时间】:2015-03-13 19:28:58
【问题描述】:

我有一个简单的问题 w.r.t.仅在 IE9 中用于背景颜色的 alpha 不透明度。

我正在复制使用的代码,

HTML:

<div class="dropdown custom-select-lang">
    <select name="one" class="languageDrop dropdown-select">
        <option value="1">ENGLISH</option>
        <option value="2">Option #1</option>
        <option value="3">Option #2</option>
    </select>
</div>

CSS:

.dropdown { display: inline-block; position: relative; overflow: hidden; height: 38px; width: 110px; background: rgba(255,255,255,0.9);}

.dropdown:after { content: ''; position: absolute; z-index: 2; top: 9px; right: 10px; width: 0; height: 0; border: 4px dashed; border-color: #888888 transparent; pointer-events: none;}

.dropdown:after { margin-top: 8px; border-top-style: solid; border-bottom: none;}

.dropdown-select { position: relative; width: 130%; margin: 0; padding: 6px; height: 38px;  font-size: 12px; color: #62717a; border: 0; border-radius: 0; -webkit-appearance: none; float: left;}

我还使用了以下仅适用于 IE9 的 hack:

/* IE9 only */
:root .currChangeDrop.dropdown-select{ width: 150%; background: rgba(255,255,255,0.9);}

【问题讨论】:

    标签: css internet-explorer opacity


    【解决方案1】:

    我看到您将背景添加到错误的 div 中。 将背景添加到您的 .dropdown-select 类中

    所以你的班级现在看起来像下面这样:

    .dropdown-select {background: rgba(255,255,255,0.5); position: relative; width: 130%; margin: 0; padding: 6px; height: 38px;  font-size: 12px; color: #62717a; border: 0; border-radius: 0; -webkit-appearance: none; float: left;}
    

    仅 IE8 不需要 IE9 的 css hack

    让我知道这是否有效

    ...

    【讨论】:

    • 我有下拉选择类的背景颜色。但它仍然无法正常工作。
    • 为什么不直接制作一个 1px x 1px 的透明 png 背景图像并将其添加到您的 CSS 中始终有效?这样你就不需要任何黑客或担心跨兄弟兼容性....@PratikBasak
    • 感谢您的解决方案。我试图避免使用任何类型的图像,所以它跳过了我的想法..谢谢。
    【解决方案2】:

    两种解决方案,选择你喜欢的。

    要么在您的标记上添加一个类.transparent,然后在您的样式表中添加以下代码:

    .transparent {
        zoom: 1;
        filter: alpha(opacity=50);
        opacity: 0.5;
    }
    

    或者简单地将其添加到您的 css 声明中。

    .you-selector {
       /*some stuff here*/
       filter: alpha(opacity=50);
    }
    

    [css-tricks]http://css-tricks.com/css-transparency-settings-for-all-broswers/建议第一个解决方案

    【讨论】:

      猜你喜欢
      • 2011-01-25
      • 2015-04-17
      • 1970-01-01
      • 1970-01-01
      • 2012-09-09
      • 2010-10-11
      • 2014-04-02
      • 2023-03-24
      • 2011-02-24
      相关资源
      最近更新 更多