Tutorial & code

Image Swap on Hover

This shows a column (or child column) background image until a mouse hover show the Beaver Builder photo module image.

Minimum BB plugin required:      Saved under:  
Skill level:     Contributor: 

Template Location

Bj Custom Rows Nav 1

Video

Notes

With Beaver Builder small optimized background images seem to load faster than those in the image module. This could be down to native lazy loading in WordPress. If you see a flash of the photo image perhaps try reversing the opacity in the CSS below and swap the image over.

See the Image Swap on Hover template in action.

Code

CSS

@media (min-width: 992px){ /* This hides the photo image on desktops only. 
Remove this line and the last } if you want the column background image to show in mobile devices. 
Remember there's no hover over on mobile devices*/

.fl-module-content img{
opacity:0;
transition: .8s ease-in-out /* adjust the transition speed */
}

.fl-module-content img:hover{
opacity:1;
transition: .8s ease-in-out; /* adjust the transition speed */
}

} /* Remove this if deleting @media */

/*
The photo module image is hidden until hovered over.
This could be reversed, but you can get a flash of the background image on page load.
*/


Can you improve this template?

We'd love it if you can so please comment and share.

For help please post to the Beaver Builder Beginners Facebook group or the YouTube video with this post.

Leave a Comment