Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue on adding Box Shadow to SVG by CSS

can you please take a look at this demo and let me know how I can add box shadow to svg using CSS?

I already tried these

.kiwi {
  fill: #94d31b; 
  box-shadow: 10px 10px 5px #888888;
  -webkit-filter: drop-shadow( -5px -5px 5px #000 );
  filter: drop-shadow( -5px -5px 5px #000 ); 
  -webkit-svg-shadow: 0 0 7px #53BE12;
}

but they didn't' add any shadow to the SVG

like image 493
Suffii Avatar asked Mar 21 '14 15:03

Suffii


1 Answers

You can add something like the following to your svg:

<filter id="drop-shadow">
  <feGaussianBlur in="SourceAlpha" stdDeviation="2.2"/>
  <feOffset dx="1" dy="4" result="offsetblur"/>
  <feFlood flood-color="rgba(0,0,0,0.3)"/>
  <feComposite in2="offsetblur" operator="in"/>
  <feMerge>
    <feMergeNode/>
    <feMergeNode in="SourceGraphic"/>
  </feMerge>
</filter>

and then use the following styles:

.kiwi {
  fill: #94d31b; 
  -webkit-filter: drop-shadow(0 1px 10px rgba(113,158,206,0.8));
  filter: url(#drop-shadow);
}

Example

like image 120
Pete Avatar answered Sep 28 '22 02:09

Pete