How to remove white border from blur background image

前端 未结 9 700
傲寒
傲寒 2020-12-28 17:23

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

CSS, i tried adding marg

相关标签:
9条回答
  • 2020-12-28 18:23

    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`
          }
        }
    
    0 讨论(0)
  • 2020-12-28 18:24

    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); 
    }
    
    0 讨论(0)
  • 2020-12-28 18:24
    padding: 10px 10px;
    

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

    0 讨论(0)
提交回复
热议问题