繁体   English   中英

自定义选择下拉箭头不可点击

[英]Customized select dropdown arrow not clickable

我正在使用以下代码来自定义我的选择下拉箭头:

HTML

<span class="selectWrapper">
    <select id="rowselect" class="pageinfoselect input-mini">
        <option>...</option>
    </select>
</span>

CSS

span.selectWrapper {
    position: relative;
    display: inline-block;
          width:65px;
}

span.selectWrapper select {
    display: inline-block;
    padding: 4px 3px 3px 5px;
    margin: 0;
    font: inherit;
    outline:none; /* remove focus ring from Webkit */
    line-height: 1.2;
    background: #f5f5f5;
    height:30px;
    color:#666666;
    border:1px solid #dddddd;
}




/* Select arrow styling */
span.selectWrapper:after {
    content: url("../images/arrow_down.png");
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    line-height: 30px;
    padding: 0 7px;
    background: #f5f5f5;
    color: white;
    border:1px solid #dddddd;
    border-left:0px;
}

这工作正常并替换默认下拉箭头,但问题是箭头图像不可点击。 如果我单击它打开的选择框,但我也希望它在我单击箭头图像时打开

添加以下规则

pointer-events:none;

编辑:

应该注意的是IE还不支持这个属性(尽管根据caniuse - 它将在IE11中得到支持)

但是,如果您仍然想要这种方法,您可以使用Modernizer或条件注释(对于IE <10)和此css hack (对于IE10) 使IE恢复为标准内置箭头

/*target Internet Explorer 9 and Internet Explorer 10:*/
@media screen and (min-width:0\0) { 
    span.selectWrapper:after
    {
        display:none;
    }
}

然而,有一个解决方法(也是一个不同的解决方案),我在这里的答案中提到 - 其中也包含此Codepen

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM