html - 如何仅在CSS中模糊背景图像

标签 html css

<分区>

您好,我正在尝试模糊背景图像,但我认为这样做效果不佳。对它的任何帮助都会增加我的能量。谢谢

这是我的 CSS

html {
  position: relative;
  min-height: 100%;
  max-width:  100%;
   background: url(img/rsz_1spring.jpg);
   background-repeat: no-repeat;
   -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
 max-width: 100%;
    overflow-x: hidden;

}

我正在尝试应用它,但它模糊了我所有的网页,只显示了背景图片。

-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);

谢谢。

最佳答案

如果您对 <html> 应用模糊然后它会模糊你的网页。

而不是将背景添加到 <html>您需要创建另一个 <div><body>与网页大小相匹配,并添加模糊效果。

示例

body {
  font-family: "Arial";
  color: #fff;
}

.page-bg {
  background: url('http://www.planwallpaper.com/static/images/general-night-golden-gate-bridge-hd-wallpapers-golden-gate-bridge-wallpaper.jpg');
  -webkit-filter: blur(5px);
  -moz-filter: blur(5px);
  -o-filter: blur(5px);
  -ms-filter: blur(5px);
  filter: blur(5px);
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -1;
}
<h1>
This is a title
</h1>

<div class="page-bg">
</div>

关于html - 如何仅在CSS中模糊背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42489776/

上一篇:html - 当应用于子 div 时悬停停止工作,当位置设置为绝对时按钮消失

下一篇:html - 使用 Flexbox 在 DIV 元素之上创建网格

相关文章:

javascript - 如何在网页上启用水平滚动

javascript - 使用 HTML5 canvas 元素和 Javascript 加载 3D 模型

css - 如何在绝对元素之后放置一个相对元素并使父 div 扩展以适应子元素?

html - 我怎样才能让这些元素在同一行?

javascript - 使用 Javascript 将 HTML 页面中的默认可见性从可见更改为隐藏

CSS : image-text alignment problem

html - 如何使用 CSS 将 div 推到底部?

html - 在每个屏幕上创建具有完美高度的部分

html - 我如何使用 Bootstrap 将 block 垂直和水平居中?

javascript - Zingchart最后一个元素一直在变颜色,与图例不匹配