Webflow sync, pageviews & more.
NEW

What is the best way to create this effect using a normal img element in Webflow instead of setting the image as a background and adding an overlay?

TL;DR
  • Wrap the image and an overlay div inside a relative positioned wrapper.
  • Set the overlay div to absolute with full coverage (top: 0, left: 0, right: 0, bottom: 0) and a semi-transparent background.
  • Use Webflow interactions on the wrapper to toggle the overlay’s opacity for hover effects.

To recreate an image overlay effect using a regular img element in Webflow (instead of using a background image), you can do this by layering a div over the image within a wrapper. Here's how:

1. Structure the Elements

  • Add a Div Block and give it a class like image-wrapper.
  • Inside the wrapper, add an Image element and upload/select your image.
  • Then, add a second Div Block inside the wrapper, placed after the image. Give this overlay div a class like image-overlay.

2. Style the Wrapper

  • Set the image-wrapper to position: relative.
  • Give it any desired width and height, or let it size to the image automatically.

3. Style the Image

  • Set the image to display: block and width: 100% (to fill the wrapper).
  • Alternatively, set the image to absolute positioning if you want more control.

4. Style the Overlay

  • Set image-overlay to position: absolute.
  • Set top, left, right, bottom to 0 — this makes the overlay cover the entire image.
  • Assign a background color (e.g., black or gradient), with opacity or use rgba, like rgba(0,0,0,0.5).
  • If you need interaction effects like hover, add an initial opacity of 0, and use Webflow interactions to change its opacity on hover.

5. Optional: Add Text or Icons in Overlay

  • You can place text or icons inside the image-overlay div.
  • Use Flexbox (center-center) on the overlay for easy alignment.

6. Use Hover Interactions (Optional)

  • Select the image-wrapper.
  • In the Interactions panel, add a hover trigger.
  • On Hover, set an animation that changes the overlay’s opacity from 0 to 1.
  • On Hover Out, reverse the opacity from 1 to 0.

Summary

To create an overlay effect on a standard img element in Webflow, wrap the image and a positioned overlay div inside a relative wrapper. Style the overlay with absolute positioning and background color, and use Webflow interactions for hover effects. This gives you full control, similar to background-image overlays but with better accessibility and loading behavior.

Rate this answer

Other Webflow Questions