SVG drop shadow using css3

后端 未结 7 1549
谎友^
谎友^ 2020-11-22 12:34

Is it possible to set drop shadow for an svg element using css3 , something like

box-shadow: -5px -5px 5px #888;
-webkit-box-shadow: -5px -5px 5px #888;
         


        
7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 13:18

    Here's an example of applying dropshadow to some svg using the 'filter' property. If you want to control the opacity of the dropshadow have a look at this example. The slope attribute controls how much opacity to give to the dropshadow.

    Relevant bits from the example:

    
       
       
      
         
      
       
         
         
      
    
    
    

    Box-shadow is defined to work on CSS boxes (read: rectangles), while svg is a bit more expressive than just rectangles. Read the SVG Primer to learn a bit more about what you can do with SVG filters.

提交回复
热议问题