Selecting all links except hovered one CSS only

后端 未结 3 1737
轮回少年
轮回少年 2021-01-22 14:15

I\'m trying to make a CSS selector that matches all links except the hovered one. Naturally I though of using the ~ operator to catch around elements:



        
3条回答
  •  长情又很酷
    2021-01-22 14:57

    Demo (with green and red color)

    css

    a {
        color: #f00;
    }
    div {
        display: inline-block;
    }
    
    #scope1:hover > a, #scope2:hover > a{
           color : #0f0; 
    }
    #scope1 a:hover, #scope2 a:hover {
           color : #f00 ; 
    }
    

提交回复
热议问题