【问题标题】:Can I apply a CSS filter to a background image?我可以将 CSS 过滤器应用于背景图像吗?
【发布时间】:2017-09-17 15:01:22
【问题描述】:

我想要这样的背景图片

body{

    background-color: transparent !important;
    background-image: url("img.jpg");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    filter: blur(5px);
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px)


}

但也有一个模糊过滤器。

但是,当我把它放在 body 上时,除了背景图像之外的所有东西都模糊了。

有没有办法只在背景图像上应用模糊? (除了在 Photoshop 或类似软件中进行模糊处理。

【问题讨论】:

    标签: css filter


    【解决方案1】:

    Blur 适用于除主体以外的任何容器的背景图像。

    filter: blur(20px)
    

    演示在这里

    https://jsfiddle.net/scheinercc/Yr2zD/1128/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-11
      相关资源
      最近更新 更多