【问题标题】:How to make this image blur with transparent dark background如何使用透明的深色背景使此图像模糊
【发布时间】:2016-12-10 00:38:55
【问题描述】:

我想用 css 实现如下图所示的图像。我的意思是我想让图像背景出现,但前面的图像应该是透明的。我的意思是它应该像模糊一样被覆盖。我想实现如下图。

img {
  -webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
position:fixed;
}
<div><img src="http://i.imgur.com/v06GqMK.jpg" /></div>

【问题讨论】:

  • 好的等等............
  • 那你还想要什么?黑暗的背景?
  • @Kode.Error404 我添加了,但我想要实现的图像如上图我的图像变得更加模糊
  • 试试这样的过滤器:filter: blur(1px) brightness(0.5);。这会使您的图像变暗。
  • 如果你正在寻找一个覆盖,那么你可以参考这篇文章stackoverflow.com/questions/18322548/…

标签: html image css blur


【解决方案1】:

这就是你想要的:

.container {
  background: url("https://d36ai2hkxl16us.cloudfront.net/thoughtindustries/image/upload/a_exif,c_fill,w_750,h_361/v1426633725/eq54w9myfn6xfd28p92g.jpg") no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  width: 750px;
  height: 361px;
  position: relative;
  text-align: center;
}

.container::before {
  content: "";
  display: block;
  -webkit-filter: blur(1px) brightness(0.5);
  -moz-filter: blur(1px) brightness(0.5);
  -ms-filter: blur(1px) brightness(0.5);
  -o-filter: blur(1px) brightness(0.5);
  filter: blur(1px) brightness(0.5);
  position: absolute;
  left: 10px;
  top: 10px;
  right: 10px;
  bottom: 10px;
  background: inherit;
  z-index: 0;
}

.content {
  position: relative;
  z-index: 10;
  padding-top: 50px;
}

.title {
  font-family: arial;
  font-size: 3em;
  color: gold;
  font-weight: 900;
  margin: 20px;
}

.text {
  font-family: arial;
  font-size: 2em;
  color: white;
  font-weight: 100;
  padding: 20px;
  border: 1px solid gray;
  display: inline-block;
  width: 40%;
}
<div class='container'>
  <div class='content'>
    <div class='title'>Content Marketing</div>
    <div class='text'>6 Essential Elements You Can't Ignore</div>
  </div>
</div>

【讨论】:

  • 伟大的工作。谢谢。小说明:如果有人想去除模糊效果的填充,请将左上右下减小到 0.1px。
【解决方案2】:

您可以使用 CSS 伪元素或其他 html 元素来实现这一点。 这是一个使用伪元素的示例:before

.blur {
  position: relative;
  display: inline-block; /* make the div not 100% */
}
/* the 'blur' effect */
.blur:before {
  content: '';
  background-color: #000;
  opacity: 0.5;
  width: 100%;
  height: 100%;
  z-index: 1;
  position: absolute;
  top: 0;
  left: 0;
}
.blur img {
  display: block; /* remove bottom space */
}
<div class="blur">
  <img src="http://i.imgur.com/v06GqMK.jpg" />
</div>

【讨论】:

    【解决方案3】:

    只需使用linear-gradient()

    background: linear-gradient(0deg, rgba(0, 0, 0, 0.50), rgba(0, 0, 0, 0.50)), url('image.png');
    

    应该做的伎俩。干杯。

    【讨论】:

      【解决方案4】:
      User this
      
      <!DOCTYPE html>
      <html>
      <head>
      <style>
      div.background {
        background: url(klematis.jpg) repeat;
      
        border: 2px solid black;
        -webkit-filter: blur(2px);
      -moz-filter: blur(2px);
      -o-filter: blur(2px);
      -ms-filter: blur(2px);
      filter: blur(2px);
      }
      
      div.transbox {
        margin: 0px;
        background: #fff;
        border: 1px solid black;
        opacity: 0.5;
      
      }
      
      div.transbox p {
        margin: 5%;
        font-weight: bold;
        color: #000000;
      }
      </style>
      </head>
      <body>
      
      <div class="background">
        <div class="transbox">
          <p>This is some text that is placed in the transparent box.</p>
        </div>
      </div>
      
      </body>
      </html>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-06
        • 2016-12-08
        • 2022-01-17
        • 1970-01-01
        • 2016-06-24
        • 2013-06-05
        相关资源
        最近更新 更多