I have an issue where my hover over images and the original image are both showing on top of one another when lazy loaded using the following code:
[x_image type=“circle” float=“none” src=“https://emilycolin.com/wp-content/uploads/2016/06/barnes__noble.png”][x_image type=“circle” float=“none” src=“http://emilycolin.com/wp-content/uploads/2016/06/barnes__noble_hover.png”]
I’ve excluded “x-img-circle” from lazy loading as a result. But now they are killing my lighthouse score, so I need to find a way to swap the images with some kind of CSS magic, but I can’t seem to find a way that was as responsive as whet I was using.
Here’s an example of what I have so far for each rollover:
/* Bookshop */
background: url(https://emilycolin.com/wp-content/uploads/2020/07/book_shop.png) no-repeat;
border-top-left-radius: 50% 50%;
border-top-right-radius: 50% 50%;
border-bottom-right-radius: 50% 50%;
border-bottom-left-radius: 50% 50%;
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
/* GRID OF EIGHT */
This works great for all eight images except for having to assign the width and height a pixel value. I tried a percentage value and failed miserably, as I’m sure you know.
Is there a responsive way to do this so that as the browser size decreases, so does the two images that are being swapped? If not, I’ll need to resize the images for each breakpoint to work with an @media declaration in the CSS.
You can see what I’m tinkering around with at https://emilycolin.com/test/
Any guidance would be greatly appreciated.