Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter drop-shadow is causing images to blur

I have a png image I'd like to have a subtle drop shadow beneath. So I created a class .drop-shadow

img.drop-shadow{
    -webkit-filter: drop-shadow(3px 3px 3px rgba(0,0,0,0.1));
    filter: drop-shadow(3px 3px 3px rgba(0,0,0,0.1));}

However, when I apply this class to an image then it becomes blurry. You can see a screen shot of this before and after at the link below.

Screenshot of blurry image

Is it possible to avoid this blurring? I tried block-shadow but this only works for rectangular images.

Here's the other css applied to the image just incase it is relevant.

img {
display: block;
max-width: 200px;
width: 100%;
margin: 1rem auto;
margin-bottom: $body-line-height;
padding-top: 0;}

Here's a codepen to make it a bit easier http://codepen.io/patrickaltair/pen/cHsbj

like image 833
patrick.altair Avatar asked Nov 02 '25 06:11

patrick.altair


1 Answers

This seems to be a bug with the -webkit filters on Retina screens.

Quick fix: Add this to your css file:

img {
    -webkit-transform: translateZ(0);
}

I can't test if it's working, as I don't have a retina screen, but please let me know if it does.

like image 167
johanpw Avatar answered Nov 04 '25 21:11

johanpw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!