简体   繁体   English

在悬停时更改svg颜色?

[英]Change svg color on hover?

Here is the code that i have 这是我的代码

div.dashboard
    svg#menu-btn
        image(xlink:href="/static/icons/svg/menu-1.svg")

and the css is 而css是

#menu-btn:hover {
    margin-left: 5px;
    height: 50px;
    width: 50px;
    fill: red;
    image {
        height: 50px;
        width: 50px;
        fill: red;
    }
}

The color of the svg is still black and doesn't turn red. svg的颜色仍然是黑色,不会变成红色。 Where am i going wrong ? 我哪里错了?

I suppose you'll have to inline your SVG to make it work that way. 我想你必须内联你的SVG才能让它以这种方式工作。 A second way to do so must be to use css filters or mask, but it is a bit harder. 第二种方法必须是使用css过滤器或掩码,但它有点难。

You have to specify the fill for the hover state. 您必须指定悬停状态的fill

svg#menu-button:hover{
     fill:red;
     cursor:pointer; /*to change the cursor*/
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM