html - IE9-IE10 - 无法点击绝对定位的元素

标签 html internet-explorer css less

我有这个搜索字段:

enter image description here

右边的“x”是清除文本。它适用于除 IE9/10 以外的所有浏览器。

据我所见,一旦图标位于输入上方,它就不再可点击,就像输入覆盖它一样(尽管它是可见的)。如果我将图标向右移动一点,使其不在输入上,它会按预期运行。

我尝试更改 z-index 但没有成功。

HTML:

<div class="capbSearchPanel" data-bind="with: searchVM">
    <div class="capbWrapper">
        <a href="#" class="capbBtn capbBtnCancel cafeLeft">Cancel</a>
        <div class="capbSearchInputWrapper cafeLeft">
            <span class="capbIcon capbClearTextIcon"></span>
            <span class="capbIcon capbSearchIcon"></span>
            <input  type="search" class="capbSearchInput"  autofocus="true" placeholder="Search For Anything..."/>
        </div>
        <a href="#"><span class="capbIcon cafeLeft"></span></a>
    </div>
</div>

少:

/* SEARCH FIELD*/
.capbSearchInputWrapper{
    position: relative;
    display: inline-block;

    input{
        width: 100%;
        height: 31px;
        background-color: #fff;
        padding: 0px 26px 0 27px;
        border: solid 1px #c0c0c0;

        //iPads (landscape) -----------
        @media only screen
        and (min-device-width : 768px)
        and (max-device-width : 1024px)
        {
            padding-top: 5px;
        }
    }

    .capbIcon{
        line-height: 20px;
        position: absolute;
        top: 50%;
        width: 24px;
        margin-top: -12px;

        //iPads (landscape) -----------
        @media only screen
        and (min-device-width : 768px)
        and (max-device-width : 1024px)
        {
            margin-top: -13px;
        }

    }
    .capbSearchIcon{
        // content: url('@{capbImgPath}/icon_search_323232.svg');
        left: 5px;
        &:before{
            height: 25px;
            content: url('@{capbImgPath}/icon_search_323232.svg');  
        }       
    }

    .capbClearTextIcon{
        right: 5px;
        z-index: 10;
        &:before{
            height: 25px;   
        }
    }

}

最佳答案

因为您在 .capbClearTextIcon 的“之前”伪元素上设置了一个高值,我猜该图标也是通过该伪元素定义的? 如果是这样,您是否尝试将图标放在真实范围内而不是伪元素中? 像这样:

.capbClearTextIcon {
    background-image: url('@{capbImgPath}/icon_close_323232.svg');
    background-repeat: no-repeat;
    display: inline-block;
    content: "";
    height: 25px;
    width: 25px;
}

关于html - IE9-IE10 - 无法点击绝对定位的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17296665/

相关文章:

jquery - 将 html5 canvas 保存为服务器中的图像

html - 如何在IE中提供水平和垂直滚动条

javascript - 懒网 : Is there something funny about how IE7 does onMouseOver Javascript on li elements with text?

javascript - jQuery :contains() selector is not working IE

css - 如何使用 css 更改表格的样式?

html - XPath : Extract the text located after a specific string of characters

javascript - 在表单输入中显示来自对象的正确数据

css - 在 flexbox 中填充 <img> 并在没有 JavaScript 的情况下保留纵横比

html - 在现代浏览器中我们需要像 rem 这样的响应单元吗?

html - 粘性页脚不适用于全宽 slider