CSS“和”和“或” [英] CSS "and" and "or"

查看:112
本文介绍了CSS“和”和“或”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很大的麻烦,因为我需要通过样式化一些输入类型的anathematise。我有类似的:

  .registration_form_right input:not([type =radio)
{
// Nah。
}

但我不想对复选框进行样式设置。



我试过:

  .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])

如何使用&&& ?我很快就需要使用 || ,我认为用法会一样。



更新:

我仍​​然不知道如何使用 || && / code>正确。我在W3文件中找不到任何内容。

解决方案

&&& 通过将如下所示的多个选择器串接在一起来实现:

 < div class =class1 class2> / div> 


div.class1.class2
{
/ * foo * /
}

另一个例子:

 < input type =radioclass = /> 

input [type =radio]。class1
{
/ * foo * /
}
pre>

||通过使用逗号分隔多个选择器来工作:

 < div class =class1>< / div& 
< div class =class2>< / div>

div.class1,
div.class2
{
/ * foo * /
}

注意,我建议不要使用not选择器,因为它不受Internet Explorer支持。根据一项调查,60%的人使用某种版本的Internet Explorer,因此您的网站不会为很多人工作。


I've got quite big trouble, because i need to anathematise from styling some input types. I had something like:

.registration_form_right input:not([type="radio")
{
 //Nah.
}

But i don't want to style checkboxes too.

I've tried:

.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"])

How to use &&? And I'll need to use || soon, and I think that usage will be same.

Update:
I still don't know how to use || and && correctly. I couldn't find anything in W3 docs.

解决方案

&& works by stringing-together multiple selectors like-so:

<div class="class1 class2"></div>

div.class1.class2
{
  /* foo */
}

Another example:

<input type="radio" class="class1" />

input[type="radio"].class1
{
  /* foo */
}

"||" works by separating multiple selectors with commas like-so:

<div class="class1"></div>
<div class="class2"></div>

div.class1,
div.class2
{
  /* foo */
}

As a side note, I would recommend against using the "not" selector because it is not supported by Internet Explorer. Based on one survey, 60% of people use some version of Internet Explorer, so your website will not work for a lot of people.

这篇关于CSS“和”和“或”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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