SVG gradient using CSS

前端 未结 6 1277
粉色の甜心
粉色の甜心 2020-11-29 19:58

I\'m trying to get a gradient applied to an SVG rect element.

Currently, I\'m using the fill attribute. In my CSS file:

rec         


        
6条回答
  •  时光说笑
    2020-11-29 20:10

    Just use in the CSS whatever you would use in a fill attribute. Of course, this requires that you have defined the linear gradient somewhere in your SVG.

    Here is a complete example:

    rect {
        cursor: pointer;
        shape-rendering: crispEdges;
        fill: url(#MyGradient);
    }
    
          
          
            
              
              
            
          
          
          
        

提交回复
热议问题