JavaScript 跨浏览器的 Webkit 背景过滤器

Webkit Backdrop Filter with JavaScript cross-browser

我看过这个新的令人惊叹的演示

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

我想问一下如何用 JavaScript 重现这个至少在 Chrome 中有效但也可能在 Firefox 中有效?

演示: https://webkit.org/demos/backdrop-filter/

您可以试试 svg 过滤器:

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>

我还没有进行跨浏览器检查,但支持非常广泛: http://caniuse.com/svg-filters