Selecting a sibling of a parent

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

I\'ve got this HTML:


   
      user
   
   message


        
相关标签:
2条回答
  • 2021-01-27 04:09

    You cannot move a level up to an element´s parent using CSS.

    0 讨论(0)
  • 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

    <font>
       <a href="profile/user"><b>user</b></a>
       <font>message</font>
    </font>
    

    and you can do this:

    a[href*="user"] + font { /* YOUR STYLES HERE */ }
    
    0 讨论(0)
提交回复
热议问题