【问题标题】:hide select dropdown arrow in ie9在ie9中隐藏选择下拉箭头
【发布时间】:2013-11-20 12:58:10
【问题描述】:

我在 IE 中使用过以下代码,它仅适用于 IE 10,但不适用于 IE 8、9 - 选择下拉箭头至少要隐藏 IE9。请帮帮我。

<select  class="dropDown">
    <option>mango</option>
    <option>banana</option>
    <option>pomegranate</option>
    <option>papaya</option>
</select>


select.dropDown {
    outline : none;
    overflow : hidden;
    text-indent : 0.01px;
    text-overflow : '';
    background : #666;

    -webkit-appearance: none;
    -moz-appearance: none;
    -ms-appearance: none;
    -o-appearance: none;
    appearance: none;
}
select.dropDown::-ms-expand
    display: none;
}

【问题讨论】:

  • 1.定义不起作用。 2. IE appearance 属性。 3. 将text-indent 值设置为0.01px 没有意义。大于 0 的最小可能值为 1。
  • 另见How to hide drop down arrow in ie9,这是一个精确的副本。
  • 外观是新的。

标签: css


【解决方案1】:

如 cmets 中所述。 IE 9 及更低版本不支持 appearance 属性。我在过去创造了类似的东西。基本上我所做的是在选择元素的箭头顶部创建一个元素。

元素只是绝对定位,背景是静态的,和网页背景一样:

selectbox
{
    position: relative;
    width: 200px;
    height: 200px

}

label 
{
    display: inline-block;
    position: absolute;
    right: 0;
    height: 23px;
}

label:after 
{
    content: '';
    width: 16px;
    height: 23px;
    position: absolute;
    right: 2px;
    color: #868583;
    background: white;
    border-left: 1px solid #868583;
    padding-left: 2px;
}

label > select 
{
    float: right;
    background: transparent;
    border: 1px solid #575757;
    color: #575757;
    font-size: 14px;
    letter-spacing: 2px;
    font-family: Arial;
    height: 100%;
}

当您希望能够点击通过重叠元素时,您可能希望在重叠元素上使用pointer-events: none;

我显示了轮廓焦点,所以你看不到它勾勒出原始选择框的宽度:

select::-moz-focus-inner {
  border: 0;
}

select:focus
{
  outline: none;
}

jsFiddle

这只是我做的一个简单的例子,希望你觉得它有用。

更新

您可以在用户使用 IE 时使用此代码,否则您可以使用您的代码。

【讨论】:

  • 谢谢你给我jsFiddle链接,但是IE10,9都不能正常工作,你检查了吗? nkmol
  • 我真的以为我测试过了,我的错!用新的jsFiddle 修复它。您可以将其与 this 之类的组合使用。
  • 再次感谢,但如果我在 IE10 中单击它,则会在右侧增加 9 个下拉菜单。我们想要简单的下拉菜单。比如chrome和firefox。你能修复一下 nkmol 吗?
  • IE10 默认行为与 chrome 中的行为不同(与 IE9 相同。我可以更改 IE9,但您可能不会自己尝试:jsFiddle 我希望这个答案有用,不要忘记接受我的答案:)
猜你喜欢
  • 2013-10-24
  • 2015-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-20
  • 1970-01-01
  • 1970-01-01
  • 2014-12-04
相关资源
最近更新 更多