CSS Change color on hover

前端 未结 5 1054
名媛妹妹
名媛妹妹 2021-01-23 18:54

I\'m trying to override my first \"color change\" with a second. I\'d like to have a silver color on my icon, when hover the text, and red color icon when hovering the icon.

5条回答
  •  Happy的楠姐
    2021-01-23 19:33

    You were almost there. The problem is that the first selector is more specific than the second and therefore it takes precedence. You can easily fix that without any !important keywords by simply specializing the second selector:

        .delDoc {
          color: transparent;
          font-size: 12px;
          cursor: pointer;
        }
        
        .liDoc:hover > .delDoc {
          color: silver;
        }
        
        .liDoc > .delDoc:hover {
          color: red;
        }
    
    

提交回复
热议问题