Explore how to enhance your website’s interactivity with this simple guide on implementing a logo or image swap effect upon mouse hover. Ideal for web designers and developers, this tutorial includes step-by-step instructions, complete with HTML and CSS code snippets, to seamlessly integrate this dynamic visual cue into your web project. Perfect for adding that extra flair to logos or images on your site, learn how to create a more engaging user experience with ease.
DEMO: Swapping Logo/Image on Hover of Mouse
HTML
<div class="swap"> <a href="https://wedesignorange.com"> <img class="main" src="YOUR-MAIN-IMAGE" /> <img class="hover" src="YOUR-SWAPPING-IMAGE" /> </a> </div>
CSS
.swap { height: 200px; width: 200px; position: relative; } .swap img { position: absolute; top: 0; right: 0; left: 0; bottom: 0; transition: opacity .9s; width: 100%; height: 100%; object-fit: contain; } .swap img.hover, .swap:hover img.main { opacity:0; } .swap img.hover:hover { opacity:1; }