Combine CSS Attribute and Pseudo-Element Selectors?

前端 未结 1 1724
既然无缘
既然无缘 2020-11-29 11:43

How can I combine a pseudo-element selector (:after) with an attribute selector ([title])?

I tried using div[title]:after, but

相关标签:
1条回答
  • 2020-11-29 11:56

    This looks like a bug, which has finally been reported. If you add a CSS rule for div[title] anywhere in your stylesheet with at least one declaration, your div[title]:after rule will magically apply. For example:

    div:after {
        content: "NO";
    }
    div[title] {
        display: block;
    }
    div[title]:after {
        content: "YES";
    }
    

    See the updated fiddle.

    It also seems to have something to do with your second div having or not having certain HTML attributes, as shown in the comments below.

    0 讨论(0)
提交回复
热议问题