美文网首页
IE下input框遮挡了按钮

IE下input框遮挡了按钮

作者: 阳光小羊羊的草场 | 来源:发表于2017-08-07 17:29 被阅读0次

在做搜索框的时候打算用position:absolute;将按钮放在input框上,但是IE9和IE8中,按钮始终被input压在后面。

效果图

HTML结构如下:

   <div class="sidebar-search" id="siderbar-search">
        <input type="text" placeholder="功能搜索" id="sidebarSearchInput" onkeypress="sidebarSearchKeypress();"/>
        <span class="sidebarSearchBtn" onclick="sidebarSearch(event);" id="sidebarSearchBtn"></span>
        <div class="dropdown-menu"><ul></ul></div>
  </div>

CSS:

.sidebar-search {
    margin: 5px;
    position: relative;
}
.sidebar-search input[type="text"] {
    border: 0;
    width: 100%;
    box-sizing: border-box;
    font-size: 13px;
    outline: none;
        background: #fff url(../img/5.png) 98% center no-repeat;
        padding-right: 28px;
}
.sidebarSearchBtn {
    position: absolute;
    width: 28px;
    height: 30px;
    background: transparent;
    right: 5px;
    top: 5px;
    z-index: 10;
    cursor: pointer;
}

解决办法:
1. 给按钮加个背景,比如:background: #fff;(background:transparent;无效)
2. 将.sidebar-search input的背景放到外层div上(.sidebar-search),给input设置小一点的宽度,给按钮留出位置。

.sidebar-search {
    margin: 5px;
    position: relative;
    background: #fff url(../img/5.png) 98% center no-repeat;
    border: 1px solid #d5d5d5;
}
.sidebar-search input[type="text"] {
    border: 0;
    width: 172px;
    box-sizing: border-box;
    font-size: 13px;
    outline: none;
}
.sidebarSearchBtn {
    position: absolute;
    width: 28px;
    height: 30px;
    background: transparent;
    right: 0px;
    top: 0px;
    z-index: 10;
    cursor: pointer;
}

参考:http://blog.csdn.net/zhouruitao/article/details/6038008

相关文章

  • IE下input框遮挡了按钮

    在做搜索框的时候打算用position:absolute;将按钮放在input框上,但是IE9和IE8中,按钮始终...

  • 去掉ie上input的删除和眼睛小图标

    IE10默认在input框中输入内容后会显示一个‘X’按钮,方便删除输入的所有内容。 在password输入框显示...

  • IE下input框后面默认带有X,去除方法

    在IE9下,input框带有X,如何去除? 去除IE下input带x的方法,很简单,只需要css中加一句话就行了 ...

  • Tailwind Component

    按钮(button) 带符号的按钮 输入框(input) 普通输入框 邮箱输入框 文本域(textarea) 搜索...

  • ie 下input光标位置垂直不居中问题

    ie 下input光标位置垂直不居中问题 input输入框用一个背景图模拟,设置height和line-heigh...

  • 第四天

    1、Form:包裹标签,action:# Input:文本框,单选按钮,多选按钮。提交的按钮,按钮,重置的按钮。 ...

  • 表单

    input type text : 文本框 password : 密码框 submit: 提交按钮 ra...

  • 去除IE10自带的清除按钮

    最近在工作中碰到了一个问题,原本在IE8,IE9下正常的input表单,在IE10下会出现清除按钮,即表单右侧会出...

  • 表单指令

    大小于号input type=text 文本框password密码框submit提交按钮reset重置按钮ch...

  • 文本框整体删除及运算校验

    需求:1.通过点击按钮和运算符将按钮和运算符的文字赋值到input框中,input框不能输入,但是可以删除,以及光...

网友评论

      本文标题:IE下input框遮挡了按钮

      本文链接:https://www.haomeiwen.com/subject/scualxtx.html