Webkit Background Image Filter with JavaScript Cross Browser

I saw this amazing demonstration of the new

-webkit-backdrop-filter: blur(Xpx); 

and I would like to ask how to reproduce this using JavaScript, which at least works in Chrome, but perhaps in Firefox too?

Demo: https://webkit.org/demos/backdrop-filter/

+8
javascript css3 webkit
source share
1 answer

You can try svg filters:

http://codepen.io/MakiBM/pen/YGEgQK?editors=1000

 <svg x="0px" y="0px" width="500px" height="500px" viewbox="0 0 500 500"> <defs> <filter id="blur" x="0%" y="0%" height="100%" width="100%" primitiveUnits="userSpaceOnUse"> <feGaussianBlur x="50" y="50" width="400" height="400" stdDeviation="10" in="SourceGraphic" result="blurImg"/> <feComponentTransfer in="blurImg" result="opaqueBlur"> <feFuncA type="linear" intercept="1"/> </feComponentTransfer> <feBlend mode="normal" in="opaqueBlur" in2="SourceGraphic"/> </filter> </defs> <image filter="url(#blur)" x="10" y="10" id="svg-image" width="100%" height="100%" xlink:href="https://www.nycgovparks.org/photo_gallery/full_size/14413.jpg" /> <rect x="50" y="50" height="400" width="400" fill="rgb(255,255,255)" fill-opacity="0.2" /> </svg> 

I did not do crossbrowser validation, but the support is very broad: http://caniuse.com/svg-filters

+2
source share

All Articles