浏览器使用什么 CSS 来设置无效的 <input type="email">s 样式? [英] What CSS is used by browsers for styling invalid <input type="email">s?

查看:21
本文介绍了浏览器使用什么 CSS 来设置无效的 <input type="email">s 样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以在 HTML5 浏览器中你可以:

OK, so in HTML5 browsers you can have:

<input class="txt-box" type="email" name="email" rel="required" />

当电子邮件格式不正确时,它会在其周围放置一个红色框.

When the email is not in the proper format it puts a red box around it.

我的问题是:决定该样式的 CSS 是什么?

My question is: what is the CSS that determines that style?

推荐答案

取决于浏览器.这应该涵盖您的基础:

Depends on the browser. This should cover your bases:

input:invalid, input:-moz-ui-invalid {
    border:0;
    outline:none;
    box-shadow:none;
    -moz-box-shadow:none;
    -webkit-box-shadow:none;
}

在兼容的浏览器中测试效果:

Test out the effect in a compliant browser:

input[type="email"] {
    border:0;
    outline:none;
    box-shadow:none;
}

符合 IE7 要求:

input.txt-box {
    border:0 !important;
    outline:none !important;
    box-shadow:none;
}

https://developer.mozilla.org/en/CSS/%3Ainvalid

示例:http://jsfiddle.net/AlienWebguy/cUgW4/

这篇关于浏览器使用什么 CSS 来设置无效的 &lt;input type="email"&gt;s 样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆