input框的默认bug解决办法

input框的默认bug是在没干掉边框的情况下是不能设置背景颜色的,否则边框会变成内边框(黑色)效果,很难看。

解决办法是:

none掉input框的边框:border:none;

再设置其背景色为任何颜色就没问题了。

但是,此时你要是想给这个input框一个看上去的边框怎么办,因为none掉了,所以解决办法是:

在input框的外层加个div来产生边框效果,input被包含在内只用改变其背景即可。写法如下:

 <td colspan="3" class="t_content">
      <div class="t_control">
          <input type="text" />
       </div>
 </td>

.t_control{
    border: 1px solid #c9cccc;//边框效果只能由div来实现
    height: 28px;
    98.7%;
}
.t_control input{
    border: none;//只有干掉边框才能设置input的背景色background
    height: 26px;
    99%;
    padding-left: 5px;
    background: #fff;
}

原文地址:https://www.cnblogs.com/koleyang/p/5512121.html