是否有CSS“haschildren”选择器? [英] Is there a CSS "haschildren" selector?

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

问题描述

有没有css选择器,只有当子元素存在时才可以使用?

Is there a css selector I can use only if a child element exists?

请考虑:

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

我想应用 display:none 如果它没有至少一个子元素< li> 元素,则只有div。

I would like to apply display:none to div only if it doesn't have at least one child <li> element.

可以使用这个?

推荐答案

不,不可能使用CSS选择器。

Nope, unfortunately that's not possible with CSS selectors.

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

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