简体   繁体   English

如何删除Chrome中输入字段的3D边框

[英]How to remove 3D border of input filed in Chrome

I want to add blue shadow highlight for text input when it receives focus: 我希望在获得焦点时为文本输入添加蓝色阴影高亮显示:

input:focus {
    box-shadow:0px 0px 5px #6192D1;
    -webkit-box-shadow: 0px 0px 5px  #6192D1;
    -moz-box-shadow: 0px 0px 5px  #6192D1;       
    outline: 0;
}

In Firefox it looks well, but Chome adds some inner 3d looking borders. 在Firefox中它看起来很好,但Chome添加了一些内部3D外观边框。

JSFiddle 的jsfiddle

Chrome adds following styles: Chrome添加了以下样式:

border-top-style: inset;
border-top-width: 2px;
border-bottom-style: inset;
border-bottom-width: 2px;
border-left-style: inset;
border-left-width: 2px;
border-right-style: inset;
border-right-width: 2px;

If I set something like: 如果我设置如下:

border-width: 2px;
border-color: transparent;
border-style: inset;

Border has gone in Chrome, but in FF it makes the field resizing on focus. 边框在Chrome中已经消失,但在FF中,它会使焦点重新调整。

JSFiddle 的jsfiddle

Any ideas how to get rid of 3d border not hurting the appearence in FF? 任何想法如何摆脱3D边界不会伤害FF的外观?

First of all you are adding a 2px border on :focus , so hence, the field moves as border takes space outside the element and not inside, to get rid of the Chromes grey border, you need to use -webkit-appearance: none; 首先你要添加一个2px border :focus ,因此,当border占据元素之外的空间而不是内部时,字段会移动,为了摆脱Chromes灰色边框,你需要使用-webkit-appearance: none; and also use -moz-appearance: none; 并且还使用-moz-appearance: none; which will get rid of the grey border in chrome, and nice looking input field in firefox... 它将摆脱chrome中的灰色边框,以及firefox中漂亮的input字段......

input {
    padding: 4px;
    -webkit-appearance: none; 
    -moz-appearance: none; 
}

Demo 演示

Now, to standardize more, add border: 2px solid #eee; 现在,要标准化更多,添加border: 2px solid #eee; on the input tag input标签上

input {
    padding: 4px;
    -webkit-appearance: none; 
    -moz-appearance: none; 
    border: 2px solid #eee; /* Here */
}

Demo 2 演示2


Note: You are using general element selectors, so all the input fields will be affected, consider using a class or an id instead. 注意:您正在使用常规元素选择器,因此所有input字段都将受到影响,请考虑使用classid

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

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