css selector:除了in [英] css selector : all except ones in

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

问题描述

我在使用CSS选择器时遇到问题。我想选择所有类container,这不是在父nav:

 < body> 
< nav>
< div class =container>< / div>
< / nav>
< div class =container>< / div>
< div class =container>< / div>
< div class =container>< / div>
...
< / body>这是可能使用css选择器吗?



>解决方案:解决方案(thx诺亚)::not(nav)> .container {/ ** out your v = css here * /} 。这个工作如果.container是nav元素的直接子元素。

解决方案

 :not )> .container 

请注意,如果容器不是直接在导航栏中,有方法。


I'm having trouble using css selector. I would like to select all class "container", that are not in a parent "nav" :

<body>
    <nav>
        <div class="container"></div>
    </nav>
    <div class="container"></div>
    <div class="container"></div>
    <div class="container"></div>
    ...
</body>

Is this possible using css selector ?

SOLUTION : the solution (thx Noah) : :not(nav) > .container {/** out your v=css here */}. This work if .container is direct child of nav element.

解决方案

:not(nav) > .container

Note that this won't work if the container isn't directly within the nav, but there are ways around that.

这篇关于css selector:除了in的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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