【问题标题】:CSS filter blur not blurring edgesCSS过滤器模糊不模糊边缘
【发布时间】:2016-10-07 22:22:56
【问题描述】:

当我将模糊滤镜应用于我的标记时,边缘不会被模糊。我希望整个区域都变得模糊。

HTML

<div class="container">
  <div class="inner">
    <div class="image">

    </div>
  </div>
</div>

CSS

.container {
  width: 300px;
  height: 250px;
}

.inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.image {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: url(/images/400x300.jpg) no-repeat center center fixed;
  background-size: fill;
}

.image:before {
  left: 0;
  right: 0;
  bottom: 0px;
  content: "text";
  position: absolute;
  height: 20%;
  width: 100%;
  background: url(/images/400x300.jpg)  no-repeat center center fixed;
  background-size: fill;
  -webkit-filter: blur(12px);
  filter: blur(12px);
}

代码笔:

http://codepen.io/aaronbalthaser/pen/qNOYdE

Codepen 显示模糊区域。它有点像页脚,但您可以看到边缘没有模糊。有什么想法吗?

谢谢

【问题讨论】:

    标签: css css-filters


    【解决方案1】:

    您可以设置overflow: hidden 并稍微拉伸模糊的图像。我已将width 设置为110%,将高度设置为35%leftrightbottom 设置为-5%(添加到widthheight 的百分比)。希望这是你想要的。

    html,
    body{
      width: 100%;
      height: 100%;
      overflow: hidden;
      margin: 0;
      padding: 0;
    }
    
    body {
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    .container {
      width: 300px;
      height: 250px;
    }
    
    .inner {
      width: 100%;
      height: 100%;
      position: relative;
      overflow: hidden;
    }
    
    .image {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      background: url(http://attic24.typepad.com/.a/6a00e551101c548834017d3d4fde82970c-500wi) no-repeat center center fixed;
      background-size: fill;
    }
    
    .image:before {
      left: -5%;
      right: -5%;
      bottom: -5%;
      content: "";
      position: absolute;
      height: 35%;
      width: 110%;
      background: url(http://attic24.typepad.com/.a/6a00e551101c548834017d3d4fde82970c-500wi)  no-repeat center center fixed;
      background-size: fill;
      -webkit-filter: blur(8px);
      filter: blur(8px);
      overflow: hidden;
    }
     <div class="container">
       <div class="inner">
         <div class="image">
    
         </div>
       </div>
     </div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-24
      • 2014-08-16
      • 1970-01-01
      • 2015-05-08
      • 2021-11-09
      • 2016-08-26
      • 2015-03-26
      • 1970-01-01
      相关资源
      最近更新 更多