Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Blur Div Edges

Tags:

html

css

Using CSS,

like the following: http://gyazo.com/ff14a415cf7ac8622eb0cada3e23137f

I want to us CSS (preferably not CSS3) to get the edges and corners to have that effect, instead of just sharp egdes.

like image 576
James Mitchell Avatar asked Apr 02 '13 22:04

James Mitchell


People also ask

Can you blur a div?

Blurring the background elements of a div can be achieved using backdrop-filter . All the elements placed under the div are going be blurred by using this.

How do I blur the edges of an image in CSS?

If what you're looking for is simply to blur the image edges you can simply use the box-shadow with an inset. With CSS it's possible to create a circle. Just use "border-radius:50%". The above method for creating an image soft edge does not appear to work with 'circle' images.


1 Answers

You can achieve this effect by using a box-shadow the same color as the div's background, like this:

.blur-box {
    background-color: #555;
    box-shadow: 0 0 5px 10px #555;
}

You can adjust the second and third arguments (5px and 10px here) to tweak the relative size and blur radius (respectively) of the shadow in order to get it the way you want, and this feature is well supported by modern browsers (see: http://caniuse.com/#feat=css-boxshadow).

Here's a jsFiddle demo: http://jsfiddle.net/bXAFt/

like image 100
metadept Avatar answered Oct 24 '22 19:10

metadept