Mis*_*iur 92 css css-selectors conditional-operator
我遇到了很大的麻烦,因为我需要通过设计一些输入类型来解决问题.我有类似的东西:
.registration_form_right input:not([type="radio")
{
//Nah.
}
Run Code Online (Sandbox Code Playgroud)
但我也不想设置复选框样式.
我试过了:
.registration_form_right input:not([type="radio" && type="checkbox"])
.registration_form_right input:not([type="radio" && "checkbox"])
.registration_form_right input:not([type="radio") && .registration_form_right input:not(type="checkbox"])
Run Code Online (Sandbox Code Playgroud)
怎么用&&?我需要尽快使用||,我认为使用方法是一样的.
更新:
我仍然不知道如何使用||和&&正确.我在W3文档中找不到任何内容.
geo*_*lee 124
&& 通过将多个选择器串联在一起工作,如下所示:
<div class="class1 class2"></div>
div.class1.class2
{
/* foo */
}
Run Code Online (Sandbox Code Playgroud)
另一个例子:
<input type="radio" class="class1" />
input[type="radio"].class1
{
/* foo */
}
Run Code Online (Sandbox Code Playgroud)
|| 通过使用逗号分隔多个选择器来工作:
<div class="class1"></div>
<div class="class2"></div>
div.class1,
div.class2
{
/* foo */
}
Run Code Online (Sandbox Code Playgroud)
ken*_*ytm 41
AND(&&):
.registration_form_right input:not([type="radio"]):not([type="checkbox"])
Run Code Online (Sandbox Code Playgroud)
或(||):
.registration_form_right input:not([type="radio"]),
.registration_form_right input:not([type="checkbox"])
Run Code Online (Sandbox Code Playgroud)
小智 14
要选择性质a和bA的X元素:
X[a][b]
Run Code Online (Sandbox Code Playgroud)
要选择的属性a或b一个的X元素:
X[a],X[b]
Run Code Online (Sandbox Code Playgroud)
:notIE 不支持伪类。我得到了这样的东西:
.registration_form_right input[type="text"],
.registration_form_right input[type="password"],
.registration_form_right input[type="submit"],
.registration_form_right input[type="button"] {
...
}
Run Code Online (Sandbox Code Playgroud)
那里有一些重复,但为了更高的兼容性而付出的代价很小。
如果我们想查找在其属性中div同时包含this 和 that 的valuea ,我们可以简单地连接这两个条件,如下所示:
div[value*="this"][value*="that"]
Run Code Online (Sandbox Code Playgroud)
如果我们想要divthat 包含this OR that,您可以在两个条件之间使用逗号,如下所示:
div[value*="this"], div[value*="that"]
Run Code Online (Sandbox Code Playgroud)
注意:您可以根据需要使用任意多个条件。这绝不限于示例中所示的 2。
| 归档时间: |
|
| 查看次数: |
113467 次 |
| 最近记录: |