是否有一个选择器排除显示:没有元素? [英] Is there a selector to exclude display: none elements?

查看:94
本文介绍了是否有一个选择器排除显示:没有元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只选择父母具有显示内容的< buttons> :阻止并排除那些< buttons> ,其父母没有 display:none

I want to select only <buttons> whose parents have display: block and exclude those <buttons> whose parents have display:none.

推荐答案

如果那些 display 样式是声明为 inline ,则可以使用以下选择器: div [style * = display:none;] (如果元素具有内联包含显示:无;的样式属性,然后应用样式)

If those display styles are declared inline then you can use the following selectors: div[style*="display: none;"] (if element has inline style attribute containing "display: none;" then apply style)

属性选择器:


CSS 属性选择器根据存在的
或给定属性的值来匹配元素。

The CSS attribute selector matches elements based on the presence or value of a given attribute.

Src: https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors

在致敬包含选择器:


当基于属性值的一部分查找元素时,
但不包含完全匹配的星号*可以在选择器的方括号
中使用。星号应位于属性名称
之后,即等号之前。这样做表示
跟随的值仅需要出现或包含在
属性值内。

When looking to find an element based on part of an attribute value, but not an exact match, the asterisk character, *, may be used within the square brackets of a selector. The asterisk should fall just after the attribute name, directly before the equals sign. Doing so denotes that the value to follow only needs to appear, or be contained, within the attribute value.

Src: https://learn.shayhowe.com/ advanced-html-css / complex-selectors /

这篇关于是否有一个选择器排除显示:没有元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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