如何为“=”电子邮件“选择标签在CSS? [英] How to select label for="email" in CSS?
问题描述
代码:
< label for =email> {t _your_email}:< / label>
CSS:
label
{
display: block;
width: 156px;
cursor: pointer;
padding-right: 6px;
padding-bottom: 1px;
}
我想为电子邮件标签创建一个新的CSS,
I want to make a new CSS for the email label as it's not meant to be that wide.
推荐答案
选择器将是
label[for=email]
{
/* ...definitions here... */
}
这是一个属性选择器。注意,一些浏览器(例如IE< 8的版本)可能不支持属性选择器,但是更新的。遗憾的是,为了支持旧的浏览器,如IE6和IE7,你必须使用一个类(好吧,或其他一些结构性方法)。
It's an attribute selector. Note that some browsers (versions of IE < 8, for instance) may not support attribute selectors, but more recent ones do. To support older browsers like IE6 and IE7, you'd have to use a class (well, or some other structural way), sadly.
模板 {t _your_email}
将填写 id =email
的字段,如果没有,
(I'm assuming that the template {t _your_email}
will fill in a field with id="email"
. If not, use a class instead.)
请注意,如果您选择的属性值不符合 CSS标识符(例如,如果其中有空格或括号,或以数字开头等。),您需要围绕该值引用引号:
Note that if the value of the attribute you're selecting doesn't fit the rules for a CSS identifier (for instance, if it has spaces or brackets in it, or starts with a digit, etc.), you need quotes around the value:
label[for="field[]"]
{
/* ...definitions here... */
}
这篇关于如何为“=”电子邮件“选择标签在CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!