Difuminar una imagen a través de CSS?


En muchos teléfonos inteligentes (Samsung Galaxy II es un ejemplo) cuando navega por una galería de fotos, su copia borrosa se presenta en el fondo. Esto se puede lograr mediante CSS dinámicamente (es decir. sin la copia de la foto preparada por adelantado guardada)? ¿Hay algún tipo de filtro de imagen CSS complejo para desenfocar una imagen?

Author: user776686, 2012-12-03

6 answers

Puede usar filtros CSS3. Son relativamente fáciles de implementar, aunque solo son compatibles con webkit por el momento. Samsung Galaxy 2 del navegador debe apoyar aunque, como creo que es un navegador webkit?

 43
Author: Andy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-03 11:05:04

Con CSS3 podemos ajustar fácilmente una imagen. Pero recuerde que esto no cambia la imagen. Solo muestra la imagen ajustada.

Vea el siguiente código para más detalles.

Para hacer una imagen gris:

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

Para dar un aspecto sepia:

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

Para ajustar el brillo:

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

Para ajustar el contraste:

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

Para desenfocar una imagen:

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

También debe hacerlo para diferentes navegadores. Es decir, incluir todas las declaraciones css

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

Utilizar múltiples

 filter: blur(5px) grayscale(1);
 24
Author: Raj Sharma,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-06 10:40:29

Este código funciona para el efecto de desenfoque en todos los navegadores.

filter: blur(10px);
-webkit-filter: blur(10px);
-moz-filter: blur(10px);
-o-filter: blur(10px);
-ms-filter: blur(10px);
 9
Author: sameeuor,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-12-15 11:47:20

Sí, el uso del siguiente código le permitirá aplicar un efecto de desenfoque a la imagen especificada y también le permitirá elegir la cantidad de desenfoque.

img {
  -webkit-filter: blur(10px);
    filter: blur(10px);
}
 2
Author: JacobG182,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-17 23:06:07

Los filtros CSS3 actualmente solo funcionan en navegadores webkit (safari y chrome).

 0
Author: Aneeshmg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-30 06:11:42
img {
  filter: blur(var(--blur));
}
 0
Author: Bar Horing,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-06 06:47:32