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

前端 未结 9 824
离开以前
离开以前 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:49

    Sorry, what you'd want is some kind of :parent pseudo-class that selects the child but applies to the parent, which unfortunately does not exist (not even in CSS3).

    You'd have to do a bit of Javascript, selecting all elements matching #sidebar a:hover, then applying the red bottom border on the condition that they don't have a child IMG element.

提交回复
热议问题