'How to remove white border from blur background image

How to remove the white blur border from the background image.

<div class="background-image"></div> 

CSS, i tried adding margin:-10px but it doesn't work

.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;

 }

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



Solution 1:[1]

The simplest way to do it is by adding transform: scale(1.1). Try it here.

#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); 
}

Solution 2:[2]

Up-to-date answer (2022)

You can achieve this effect with just css by using backdrop-filter on an overlaying element.

.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;
}
<div class="blurred"></div>

Keep in mind that this is not supported in IE and it only works in firefox if it is explicitly enabled.

Solution 3:[3]

This worked for me: Added two fixed images, one with z=-1, other with z=0, blurred the first one.

Solution 4:[4]

Here's a function I settled on based on @Prime 's answer.

In order for it to work the image must be positioned inside a <div/> having the width and height of the image (explicitly set).

    function addBlur(style, radius) {
      return {
        ...style,
        // https://caniuse.com/#feat=css-filters
        filter: `blur(${radius}px)`,
        // Works around the white edges bug.
        // https://stackoverflow.com/questions/28870932/how-to-remove-white-border-from-blur-background-image
        width: `calc(100% + ${2 * radius}px)`,
        height: `calc(100% + ${2 * radius}px)`,
        marginLeft: `-${radius}px`,
        marginTop: `-${radius}px`
      }
    }

Solution 5:[5]

Use a SVG-Blur filter.

filter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='a' x='0' y='0' width='1' height='1' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='4' result='b'/%3E%3CfeMorphology operator='dilate' radius='4'/%3E %3CfeMerge%3E%3CfeMergeNode/%3E%3CfeMergeNode in='b'/%3E%3C/feMerge%3E%3C/filter%3E %3C/svg%3E#a");

"stdDeviation" is your intensity.

source

Solution 6:[6]

If the white borders are caused by the background color of the body, apply margin: 0; on body since margins are not 0 by default;

Solution 7:[7]

The blur adds transparency around the edges, so all you need to do is remove the alpha channel.

Here are a couple of examples of how to do this with SVG filters.

<filter id="omega"><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1"/></filter>

<filter id="omega"><feComponentTransfer><feFuncA type="linear" slope="10"/></feComponentTransfer></filter>

You can implement blur immediately in the SVG filter, or add a filter to remove transparency after the blur

filter: blur(50px) url(#omega);

or pure CSS

filter: blur(50px) url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><filter id="a"><feComponentTransfer><feFuncA type="linear" slope="10"/></feComponentTransfer></filter>#a');

Solution 8:[8]

I added a negative margin to the container: margin: -5px

Solution 9:[9]

padding: 10px 10px;

add this in your css to remove the white blur border for bottom

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Moaaz
Solution 2
Solution 3 Gaurav Pant
Solution 4 catamphetamine
Solution 5 XYZER
Solution 6 D D
Solution 7
Solution 8 Troy Co.
Solution 9 RAJ