通过CSS给父盒子增加一个伪类
&:after { content: ""; width: calc(100% + 80px); height: calc(100% + 80px); // width: 100%; // height: 100%; position: absolute; left: -40px; top: -40px; //背景图片继承父盒子 background: inherit; //模糊 filter: blur(20px);}
注意点一:伪类的默认宽度达不到父盒子一样,所以我们需要动态计算,增大伪类的宽高,同时定位位置向左向上偏移点。
注意点二:父盒子添加上overflow:hidden;