SVG: why does external css override inline style for text?

前端 未结 3 1380
耶瑟儿~
耶瑟儿~ 2020-12-09 08:07

I\'m playing with using an SVG gradientFill as a way to visually \'truncate\' long text strings in a d3.js chart.

It seems that an external css style for fill will o

3条回答
  •  悲哀的现实
    2020-12-09 08:48

    Because in SVG, like HTML before it, styles trump attribute styling.

    fill="red" below is NOT an "inline style", style="fill:green" IS an inline style.

    
      This will be green
    

    Like wise, if you have a style defined outside, it will win.

    
      This will be lime
    

提交回复
热议问题