Selecting a sibling of a parent

前端 未结 2 918
再見小時候
再見小時候 2021-01-27 03:42

I\'ve got this HTML:


   
      user
   
   message
         


        
2条回答
  •  终归单人心
    2021-01-27 04:12

    You cannot select the parent with CSS - you might find this an interesting read on the topic: Why we don't have a parent selector. However, you can do one of the following:

    1. Use a bit of JavaScript

    2. Change your HTML to

    
       user
       message
    
    

    and you can do this:

    a[href*="user"] + font { /* YOUR STYLES HERE */ }
    

提交回复
热议问题