Skip to content

Instantly share code, notes, and snippets.

@digisavvy
Created October 10, 2018 02:09
Show Gist options
  • Select an option

  • Save digisavvy/3487da5d1ef7f924daf5564e26459a78 to your computer and use it in GitHub Desktop.

Select an option

Save digisavvy/3487da5d1ef7f924daf5564e26459a78 to your computer and use it in GitHub Desktop.
Fade-in lazy loaded images while using WP Rocket
/* Image with 'data' attribute is hidden */
img[data-lazy-src] {
/* we set the opacity to 0 */
opacity: 0;
}
/* Image without 'data' attribute is (or becomes) visible */
img.lazyloaded {
/* prepare the future animation */
-webkit-transition: opacity .5s linear 0.2s;
-moz-transition: opacity .5s linear 0.2s;
transition: opacity .5s linear 0.2s;
/* we set the opacity to 1 to do the magic */
opacity: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment