0

I'm using Jetpack to lazy load images and wanted to fade in them nicely using CSS. I've tried adding the following CSS in my theme:

.jetpack-lazy-image {
    opacity: 0;
    -webkit-transition: .3s;
    transition: .3s;
}

.jetpack-lazy-image--handled {
    opacity: 1;
}

but that doesn’t work. I've also tried to add this to the default WP themes, however, it doesn't work as well. Could someone please let me know what I am missing?

Thank you.

2 Answers 2

0

Which part doesn't work? You might need to change your transition property to include a name, as well as a delay. Optionally add the timing:

.jetpack-lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

https://developer.mozilla.org/en-US/docs/Web/CSS/transition

0

.jetpack-lazy-image--handled is added to the img before the image actually displays unfortunately. So the opacity transition happens before the image even appears. Perhaps this is a bug in Jetpack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.