How can I create a simple image swap on mouseover element with transparent text and a colored drop shadow in Webflow?

TL;DR
  • Layer two images in a relatively positioned div and swap their opacity on hover using interactions.  
  • Add absolutely positioned transparent text with a visible drop shadow above the images, optionally animating it to appear on hover.

You're trying to swap an image on hover while also displaying transparent text with a colored drop shadow in Webflow. Here's how to achieve this using Webflow’s native interactions and styling tools.

---

1. Setup the Image Elements

  • Drag a Div Block into your Webflow canvas. Give it a class (e.g., hover-image-wrap).
  • Inside this Divadd two Image elements:
  • The default image that shows normally.
  • The hover image that will appear on mouseover.
  • Give each image a class, such as default-image and hover-image.

2. Position Hover Image for Swap Effect

  • Select the hover-image, set these styles:
  • Position: Absolute
  • Top/Left/Right/Bottom: 0
  • Width/Height: 100%
  • Opacity: 0
  • Z-index: higher than the default image (e.g., 2)
  • Also set the hover-image to display over the default by giving the parent hover-image-wrap position: relative.

3. Apply Image Swap Interaction

  • Select the hover-image-wrap container.
  • Go to the Interactions panel, choose Mouse Hover.
  • For On Hover:
  • Target the hover-image, create an animation that sets:
    • Opacity: 1
  • For On Hover Out:
  • Set the hover-image's opacity back to 0.

4. Add Transparent Text with Drop Shadow

  • Inside the same container hover-image-wrapadd a Text Block with your desired message.
  • Set these styles:
  • Color: White or fully transparent using rgba(255,255,255,0) if you want it to be invisible initially.
  • Text Shadow: Apply a colored shadow using the Text Shadow box (e.g., 2px 2px 10px rgba(255, 0, 0, 1)).
  • Position: Absolute (e.g., bottom center or wherever you prefer).
  • Make sure the text appears above the images by setting a higher Z-index (e.g., 3).

5. Reveal Text on Hover (Optional)

  • If you want the transparent text + shadow to become visible on hover:
  • Create another animation on the same hover interaction that:
    • Changes text opacity to 1 (or adjust color to visible rgba or white).

---

Summary

To create an image swap on hover with transparent text and a colored drop shadow in Webflow:

  • Layer two images and toggle opacity via an interaction.
  • Use absolute positioning and z-index to control layout.
  • Add a text element with transparent fill color but a visible drop shadow.
  • Optionally, animate the text to appear on hover for added effect.
Rate this answer

Other Webflow Questions