by zhangxinxu from http://www.zhangxinxu.com/wordpress/?p=6655
黏连效果代码
页面任意位置塞入这么一段SVG代码123456789<svg width="0" height="0" style="position:absolute;"> <defs> <filter id="goo"> <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" /> <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9" result="goo" /> <feComposite in="SourceGraphic" in2="goo" operator="atop"/> </filter> </defs></svg>
需要黏连元素的父元素css加一句1filter: url("#goo");
效果局限
- 浏览器兼容问题:ie不支持1234var ua = navigator.userAgent;if (/Safari|iPhone/i.test(ua) && /chrome/i.test(ua) == false) {document.body.classList.add('nofilter');}
CSS:123body:not(.nofilter) .target { filter: url("#goo");}
- 该效果只适用于圆形元素