去除input[type=search]的边框

本文介绍了如何解决HTML5 input type=search在Webkit浏览器中无法移除默认边框的问题。通过使用-webkit-appearance:none;样式成功实现了跨浏览器一致的表现。

转http://i.wanz.im/2011/02/04/remove_border_from_input_type_search/

新年在家其实挺无聊的,长假什么的都是浮云,然后就给自己的博客弄个新皮,试着给页面添加点新鲜的元素,什么html5,什么css3的,然后遭遇了input这货,将它的type设置为search。
html代码如下:

css代码如下:

在IE和Firefox中显示的结果跟预期的一样,但在webkit内核浏览器里,border的设置并没有被应用。

在IE和Firefox中显示的结果:
IE和Firefox中的input

在Chrome中显示的结果:
在Chrome中input

在Chrome开发人员工具查看input的样式可以看到如下的以及类似的UA样式:
Chrome开发人员工具中input的样式

我猜想是跟-webkit-appearance有关,于是到Google里淘了一篇介绍input的type为search的文章“WebKit HTML5 Search Inputs”,虽然文章提到了input的type为search时,样式编写有局限性(并非所有的css属性都可以被用户用代码覆盖),但没有提到这个问题的解决方案,但是我在评论中找到了解决办法。

在css里加入下面代码解决了:

 

从这个属性的名字看来,只要是webkit内核浏览器遇到无法用css覆盖的内置样式,应该都能通过它解决^_^

转载于:https://www.cnblogs.com/lyweb/archive/2013/03/07/2947994.html

<table cellspacing="4" style="padding: 0; table-layout: fixed;" class="inputs searchinput"> <colgroup> <col width="60px" /> <col width="210px" /> <col width="60px" /> <col width="230px" /> <col width="40px" /> <col width="200px" /> <col width="200px" /> <col /> </colgroup> <tbody> <tr> <%--<td>领域: </td> <td> <input type="text" maxlength="20" name="KnowledgeCatalog2" class="txt im" /> </td>--%> <td>时间范围: </td> <td> <input type="text" style="width: 100px" maxlength="15" name="StartTime" class="txt im Wdate" readonly="readonly" /> <%-- - <input type="text" style="width: 100px" maxlength="15" name="SearchContent2" class="txt im Wdate" readonly="readonly" />--%> </td> <%--<td>部门: </td> <td> <input id="txtDepartment" name="DeptID" value="0" type="text" class="txt im" /> </td>--%> <%-- <td> <label style="vertical-align: middle;"> <input type="checkbox" name="isinclude" checked="checked" value="1" style="vertical-align: sub;" /> 包含子部门 </label> </td>--%> <td> <input type="button" value=" 搜索 " name="search" class="bbtn bg-blue" /> </td> <td> <input type="reset" value=" 重置 " name="reset" class="bbtn2 bg-hui" /> </td> <td> <input type="hidden" name="PageIndex" value="1" /> <input type="hidden" name="PageSize" value="30" /> </td> </tr> <%--<tr>--%> <%--<td>任务名称: </td> <td> <input type="text" maxlength="20" name="SearchContent" class="txt im" /> </td>--%> <%--<td>结束时间: </td> <td> <input type="text" style="width: 100px" maxlength="15" name="EndTime" class="txt im Wdate" readonly="readonly" />--%> <%-- - <input type="text" style="width: 100px" maxlength="15" name="SearchContent3" class="txt im Wdate" readonly="readonly" />--%> <%--</td>--%> <%--<td>状态: </td> <td> <select name="Status" class="sel"> <option value="0">全部</option> <option value="1">未开始</option> <option value="2">进行中</option> <option value="3">已完成</option> </select> </td>--%> <%--</tr>--%> </tbody> </table> </form> <table class="tlist" cellspacing="1" cellpadding="1"> <colgroup> <col width="100" /> <col width="100" /> <col width="100" /> <col width="100" /> <col width="100" /> <col width="100" /> <col width="100" /> <col width="100" /> <col width="100" /> <col width="100" /> <col width="80" /> <col width="80" /> </colgroup> <thead> <tr> <th colspan="2"></th> <th colspan="3">月度</th> <th colspan="3">年度</th> <th colspan="3">总计</th> <th colspan="2">同比</th> </tr> <tr> <th class="e">序号</th> <th>行销大类(三级目录)</th> <th>开发个数</th> <th>奖励金额</th> <th>优秀知识数量</th> <th>开发个数</th> <th>奖励金额</th> <th>优秀知识数量</th> <th>开发个数</th> <th>奖励金额</th> <th>优秀知识数量</th> <th>开发个数</th> <th>奖励金额</th> </tr> </thead> 每一列加上分割线 怎么写
08-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值