Is there a selector to exclude display: none elements?

前端 未结 6 2169
醉话见心
醉话见心 2021-02-19 23:22

I want to select only whose parents have display: block and exclude those whose parents have display

6条回答
  •  一生所求
    2021-02-19 23:45

    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)

    Attribute Selectors:

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

    Src: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

    Attribute Contains Selector:

    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/

提交回复
热议问题