如何从模糊背景图像中删除白色边框

Pri*_*ime 15 html css html5 blur css3

如何从背景图像中删除白色模糊边框.

<div class="background-image"></div> 
Run Code Online (Sandbox Code Playgroud)

CSS,我尝试添加保证金:-10px,但它不起作用

.background-image {
  background: no-repeat center center fixed; 
   background-image: url('http://www.hdpaperz.com/wallpaper/original/windows-8-wallpapers-2560x1600-2311_1.jpg') ; 
  background-size: cover;
  display: block;
  height: 100%;
  left: -5px;
  top:-5px;
  bottom:-5px;
  position: fixed;
  right: -5px;
  z-index: 1;
  margin:0px auto;
  -webkit-filter: blur(5px);
  -moz-filter: blur(5px);
  -o-filter: blur(5px);
  -ms-filter: blur(5px);
  filter: blur(5px);
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;

 }
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/maio/8wq132nd/1/

小智 33

最简单的方法是添加transform:scale(1.1).在这里试试吧.

#overlay {
 position: fixed;
 left: 22.5em;
 top: 3em;
 height: 75%;
 width: 50%;
 background: url("https://s-media-cacheak0.pinimg.com/originals/ae/b4/c5/aeb4c53cab2b550187644af503a0f17e.png");
 background-size: cover;
 filter: blur(9px);
 transform: scale(1.1); 
}
Run Code Online (Sandbox Code Playgroud)

  • 认为这会使图像缩放更大,如果您希望图像保持相同大小并且只想去除白色边框,则不是很完美 (2认同)
  • 它还为 webkit 浏览器中的溢出创建了一个滚动条,即使使用 overflow: hidden 也无法删除。请参阅:/sf/ask/1168091641/ (2认同)
  • 我将“overflow:hidden”添加到父 div 中,以消除“transform:scale(1.1)”创建的滚动条。 (2认同)

W4G*_*4G1 26

最新答案 (2021)

您可以通过backdrop-filter在覆盖元素上使用 css 来实现此效果。

.blurred::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(10px); /* apply the blur */
  pointer-events: none; /* make the overlay click-through */
}

.blurred {
  position: relative;
  width: 500px;
  height: 300px;
  background: no-repeat center center;
  background-image: url('https://besthqwallpapers.com/Uploads/26-5-2019/94041/thumb2-tesla-model-x-2019-exterior-front-view-new-gray-model-x.jpg');
  background-size: cover;
}
Run Code Online (Sandbox Code Playgroud)
<div class="blurred"></div>
Run Code Online (Sandbox Code Playgroud)

请记住,这在 IE 中不受支持,并且只有在明确启用的情况下才能在 Firefox 中工作。

  • 在火狐浏览器中不起作用。Firefox 默认情况下尚不支持背景过滤器。我们必须手动启用 (5认同)
  • 这样做的妙处在于,例如,如果您只想模糊背景图像的一半高度,只需在 `::before` 类上设置 `height: 50%` (2认同)
  • 多谢 !!这就像魅力一样!这个答案应该被接受! (2认同)

Pri*_*ime 6

我已经添加了溢出,填充甚至边距,但仍然没有解决问题.所以我试图在div之间给出图像标签.问题解决了.

<div class="background-image">
<img src="http://www.hdpaperz.com/wallpaper/original/windows-8-wallpapers-2560x1600-2311_1.jpg" width="100%" height="100%"/>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

 .background-image {
  background: no-repeat center center fixed; 
  background-size: cover;
  display: block;
  left: -5px;
  top:-5px;
  bottom:-5px;
  position: fixed;
  right: -5px;
  z-index: 1;
  -webkit-filter: blur(5px);
  -moz-filter: blur(5px);
  -o-filter: blur(5px);
  -ms-filter: blur(5px);
  filter: blur(5px);
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  margin:-5px;

 }
Run Code Online (Sandbox Code Playgroud)

小提琴

http://jsfiddle.net/2pgdttLh/


Gau*_*ant 5

这对我有用:添加了两个固定图像,一个 z=-1,另一个 z=0,模糊了第一个图像。