opacity vs fill-opacity in svg

后端 未结 4 916
旧巷少年郎
旧巷少年郎 2021-02-20 00:51

What is the difference in opacity vs fill-opacity in SVG?

I referred the docs for fill-opacity and opacity but I am confused what is meant by

4条回答
  •  无人及你
    2021-02-20 01:19

    In addition to affecting which parts of each individual element are affected (e.g. fill versus stroke) another difference is what happens when elements overlap within a group. opacity affects the transparency of the group as a whole while fill-opacity affects the transparency of the individual elements within the group. One consequence of this is that when elements within such a group overlap, there is a compounding effect in the region of overlap when fill-opacity is used but not when opacity is used. This is demonstrated in the image below when a (fill-)opacity of 0.5 is applied to either each element within a group or to the group itself.

    
      
        
        
      
      
        
        
      
      
        
        
      
      
        
        
      
      fill-opacity
      opacity
      applied to
      each element
      applied to
      group
    

提交回复
热议问题