简体   繁体   English

CSS:多个属性选择器

[英]CSS: Multiple Attribute Selectors

I would like to style form inputs of type "email" and "password", but not anything else. 我想样式输入“电子邮件”和“密码”类型的输入,但不是其他任何东西。 I was imagining something like the following: 我想象的是以下内容:

input[type="email"][type="password"] {
    ....
}

However, the way attribute selectors work, it appears to interpret this as "input where the type is simultaneously both 'email' and 'password'". 但是,属性选择器的工作方式,它似乎将其解释为“输入,其中类型同时是'电子邮件' '密码'”。 What I'm going for is "input where the type is either exactly 'email' or 'password'". 我想要的是“输入类型正好是'电子邮件' '密码'”。 Of course, nothing is both of type email and of type password at the same time. 当然,同时没有任何类型的电子邮件和密码类型。

Is it possible to write a CSS rule that or 's across multiple different attribute selectors? 是否可以编写一个多个不同属性选择器的CSS规则?

For reference, the HTML would look something like: 作为参考,HTML看起来像:

<form id="login" onsubmit="return fadeaway()">
    <fieldset>
    <input type="email" placeholder="username"/> <br />
    <input type="password" placeholder="password"/> <br />
    </fieldset>
</form>

这样做:

input[type="email"], input[type="password"]

use a comma : 使用逗号:

input[type="email"],input[type="password"] {
    ....
}

w3 docs on group selectors here 这里有关于群体选择器的w3文档

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

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