CSS- target text links with bottom border on hover, but image links with no border

前端 未结 9 813
离开以前
离开以前 2021-02-08 11:54

I\'d like to be able to target text links in CSS with border-bottom on hover, but have all links that are images not have a border on hover. So:



        
9条回答
  •  我在风中等你
    2021-02-08 12:28

    You can't target an element depending on what child elements it has, so you would have to add something to the code to target the different links.

    Can't you use underline instead of a bottom border? That would work as it's applied to the text in the link rather than the link element itself.

    #sidebar a:hover { text-decoration: underline; }
    #sidebar a:hover img { text-decoration: none; }
    

提交回复
热议问题