← All elements
<a class="pc-swap" href="#">
<span class="pc-swap__frame">
<span class="pc-swap__img pc-swap__img--front"></span>
<span class="pc-swap__img pc-swap__img--back"></span>
</span>
<span class="pc-swap__title">Linen Overshirt</span>
<span class="pc-swap__price">₱3,200</span>
</a>About this hover effect
A product tile that crossfades to a second image on hover and keyboard focus, built from two stacked layers and one opacity transition.
How it works
The tile has two image layers stacked in one frame. The back layer starts at opacity 0 and slightly scaled up. On hover or keyboard focus of the link, its opacity goes to 1 and its scale to normal, so the second image fades in over the first with one transition.
Ways to customise it
- Replace the two gradients with real background images.
- Change the 0.45s and 0.6s transition times.
- Change the aspect ratio of 3 / 4 for a wider or taller tile.
Good to know
Hover does not exist on touch screens, so the second image will not appear there and the first one must work alone. If the images carry information, give the link a descriptive label.
Open an example, copy the HTML and the CSS, and paste them into your page. There is nothing to install and no JavaScript to load.