Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blurring an image via CSS?

Tags:

css

image

effects

On many smartphones (Samsung Galaxy II being an example) when you browse through a photo gallery, its blurred copy is laid out in the background. Can this be achieved by CSS dynamically (ie. without the copy of the photo being prepared upfront saved)? Is there any kind of complex CSS image filter to blur an image?

like image 654
user776686 Avatar asked Dec 03 '12 10:12

user776686


People also ask

Can we blur image with CSS?

The blur() CSS function applies a Gaussian blur to the input image. Its result is a <filter-function> .

How do I blur part of an image in CSS?

You choose a suitable background-position for the outer div. Make inner div position:absolute . This is where the blur appears. Apply blur to the :before selector.

How do you blur something in CSS?

The first way of creating a blurred text is making your text transparent and applying shadow to it. The shadow will make the text appear blurred. Use a <div> with an id "blur". Then, set the color property to its “transparent” value and define the text-shadow property to give a shadow to the text.

How does blur work in CSS?

CSS | blur() Function. The blur() function is an inbuilt function which is used to apply a blurred effect filter on the image. Parameters: This function accepts single parameter radius which holds the blur radius in form of length. This parameter defines the value of the standard deviation to the Gaussian function.


3 Answers

You can use CSS3 filters. They are relatively easy to implement, though are only supported on webkit at the minute. Samsung Galaxy 2's browser should support though, as I think that's a webkit browser?

like image 150
Andy Avatar answered Oct 19 '22 21:10

Andy


With CSS3 we can easily adjust an image. But remember this does not change the image. It only displays the adjusted image.

See the following code for more details.

To make an image gray:

img {
 -webkit-filter: grayscale(100%);
}

To give a sepia look:

img {
 -webkit-filter: sepia(100%);
}

To adjust brightness:

img {
 -webkit-filter: brightness(50%);
}

To adjust contrast:

img {
 -webkit-filter: contrast(200%);
}

To Blur an image:

img {
 -webkit-filter: blur(10px);
}

You should also do it for different browser. That is include all css statements

  filter: grayscale(100%);
 -webkit-filter: grayscale(100%);
 -moz-filter: grayscale(100%);

To use multiple

 filter: blur(5px) grayscale(1);

Codepen Demo

like image 32
Raj Nandan Sharma Avatar answered Oct 19 '22 19:10

Raj Nandan Sharma


This code is working for blur effect for all browsers.

filter: blur(10px);
-webkit-filter: blur(10px);
-moz-filter: blur(10px);
-o-filter: blur(10px);
-ms-filter: blur(10px);
like image 11
sameeuor Avatar answered Oct 19 '22 19:10

sameeuor