当值为空且颜色为样式时,所需的输入字段会获得边框 [英] Required input field gets border when value is empty and color is styled
本文介绍了当值为空且颜色为样式时,所需的输入字段会获得边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Firefox中运行:
http: //jsfiddle.net/eMa8y/24/
HTML:
< HTML>
< head>
< script src =http://code.jquery.com/jquery-1.9.1.min.js>< / script>
< / head>
< body>
< form>
< input type =textplaceholder =inputrequired />
< input type =textplaceholder =input/>
< / form>
< / body>
< / html>
CSS:
input {
color:black;
}
[必填] {
颜色:红色;
}
脚本:
<$ ()函数(){
$(input)。val(); $ b($) $ b},3000);
});
等待三秒钟,输入会变成红色边框。为什么?这是一个Firefox的错误?
请注意,我使用Firefox 18.0.2。
p>
解决方案
HTML5属性 required
明显被firefox解释为包含一个红色边界,这是一个关于消除它的答案
所以只需做:
[必填] {
颜色:红色;
box-shadow:none;
}
固定
Could you explain me this?
Run this in Firefox: http://jsfiddle.net/eMa8y/24/
HTML:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
<form>
<input type="text" placeholder="input" required />
<input type="text" placeholder="input" />
</form>
</body>
</html>
CSS:
input {
color:black;
}
[required] {
color:red;
}
SCRIPT:
$(document).ready(function () {
setTimeout(function () {
$("input").val("");
}, 3000);
});
Wait three seconds and the input gets a red border. Why? Is it a bug of Firefox?
Note that I use Firefox 18.0.2.
Thanks.
解决方案
The HTML5 attribute required
is obviously being interpreted by firefox to include a red border, here's an answer about removing it
Firefox 4 Required input form RED border/outline
so just do:
[required] {
color:red;
box-shadow: none;
}
fixed
这篇关于当值为空且颜色为样式时,所需的输入字段会获得边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文