image.png

    1. body {
    2. margin: 100px;
    3. width: 300px;
    4. height: 300px;
    5. background: url("content.webp")no-repeat fixed;
    6. }
    7. main {
    8. height: 100px;
    9. color: white;
    10. padding: 20px;
    11. background: hsla(0,0%,100%,.3);
    12. position: relative;
    13. text-align: center;
    14. overflow: hidden; 把多余的模糊区域裁切掉
    15. }
    16. main::before {
    17. content: '';
    18. position: absolute;
    19. top: 0; right: 0; bottom: 0; left: 0;
    20. filter: blur(10px);
    21. background: url("content.webp")no-repeat fixed; /* 仅用于调试 */
    22. z-index: -1;
    23. margin: -20px; 接近边缘处会逐渐消退 让伪元素相对其宿主元素的尺寸再向
    24. 外扩大
    25. }