CSS选择器 - 如果子类=?然后选择父级 [英] CSS Selectors - If child class = ? then select the parent

查看:417
本文介绍了CSS选择器 - 如果子类=?然后选择父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

是否有CSS父选择器?

我有以下CSS:

<div class="div1">
    <div class="div2">
        <div class="div3">
            <ul class="div4">
                <li class="div5">

                </li>
            </ul>
        </div>
    </div>
</div>

有目标的方法, if li.div5 then target .div1 所以喜欢改变.div1的背景,如果li.div5?

Is there a way to target, if li.div5 then target .div1 so like change the background of .div1 if li.div5 ?

推荐答案

CSS 级联它只允许选择孩子。除非你实现类似 jQuery 并通过javascript执行它。没有升序选择器。

CSS cascades, so it only allows selection of children. There are no ascension selectors unless you implement something like jQuery and do it through javascript.

这篇关于CSS选择器 - 如果子类=?然后选择父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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