I am trying to use css blur filter while preserving the opacity of the image. In the example below, I have an image that is just a blue square. When I apply a blur filter, the edges become transparent and you can see the black div at the bottom. Is there any way to apply blur without introducing this transparency? Ideally, I would like it to include only visible pixels within the range in averaging. I understand that in this example, this will lead to a simple blue square, but for less trivial cases this will give the result I'm looking for.
div { background-color: black; width: 100px; height: 100px; } span { overflow: hidden; -webkit-filter: blur(30px); display: block; }
<div> <span> <img width="100px" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/000080_Navy_Blue_Square.svg/600px-000080_Navy_Blue_Square.svg.png"> </span> </div>
source share