Using CSS Target to highlight parent div

后端 未结 2 868
别那么骄傲
别那么骄傲 2021-01-28 11:14

I\'m using Ckeditor in my site to insert articles. The articles usually come from a Word document, and they have footnotes. With the last Ckeditor build (7125) I\'ve been able t

相关标签:
2条回答
  • 2021-01-28 11:43

    What you want is not possible.

    Because if the code for CSS had to check the children of an element and after that has to go back up in the DOM it would get really slow.

    So there is no Ancestor Selector in CSS.

    Perhaps you have control over the parent and can add a class (e.g. footnote) to it.

    Or you can use JavaScript to do what you want.

    0 讨论(0)
  • 2021-01-28 11:46

    Unfortunately, there is no parent or ancestor types of selectors in CSS, for the reason that it is a major problem for browser performance. However, you can achieve what you want easily with JQuery:

    $("a:target").parent().css("background", "yellow");
    
    0 讨论(0)
提交回复
热议问题