Webflow sync, pageviews & more.
NEW

How can I create a portfolio in Webflow where users can click on an image within a project template page to view a larger version? Additionally, how can I apply a dark shadow to the entire screen when the image is clicked, focusing only on the image?

TL;DR
  • Create a hidden full-screen modal with a dark overlay and centered image.
  • Trigger the modal to display via interaction when an image is clicked, and close it with a click on a close button or background.

To create a click-to-enlarge image effect with a dark overlay on a Webflow portfolio template page, you'll need to combine interactions, a lightbox-style modal, and hidden div elements. Here’s how:

1. Add a Clickable Image Inside the Project Template Page

  • On your CMS Template Page, add the desired image using an Image or Image from CMS element.
  • Wrap the image in a div block and give it a class like preview-image-wrapper.

2. Create a Lightbox Modal Structure (Hidden by Default)

  • On the template page, add a new div block outside your main content (preferably at the end of the Body).

  • Set its class to something like image-modal.

  • Style it with:

  • Position: Fixed (Full screen)

  • Background: Black with 70–90% opacity rgba(0,0,0,0.8)

  • Z-index: Higher than the rest of your content (e.g., 9999)

  • Display: Set to None initially

  • Flex display: Centered (justify: center, align: center) to center the image

  • Inside the modal, add an Image element and give it a class like modal-image.

  • Optionally, add a close button (a simple text “X” or an icon) in a corner of the modal.

3. Set Up the Interactions

  • Select the preview image and go to Interactions (IX2).

  • Create a new Mouse Click (Tap) interaction:

  • On First Click:

    • Element Action → Set image-modal display to Flex (or block)
    • Use a hide/show action and an opacity animation (from 0% to 100%) for smoother transitions
  • Select the modal-image (or even better, set it dynamically depending on the image clicked):

  • You can either:

    • Have multiple modals for different CMS items (not ideal for many projects), or
    • Use custom code to dynamically swap the source, or use one modal and dynamically update the image source using Webflow’s CMS image and some jQuery.

4. Make the Modal Close on Click

  • Add an interaction to the close button or even the entire image-modal background:
  • On Click:
    • Animate opacity to fade out
    • Then hide the modal by setting Display: None

5. Optional: Use Webflow's Lightbox Component (With Limitations)

  • You could use a Webflow Lightbox, but it can’t be bound directly to CMS-based dynamic images in a collection list on the template page.
  • To enable CMS + Lightbox, you must use custom code or third-party libraries like Fancybox or GLightbox.

Summary

To let users click an image to enlarge it with a dark screen behind:

  • Create a hidden modal div with a full-screen dark overlay.
  • Trigger it with an interaction when the image is clicked.
  • Center a larger version of the image inside.
  • Use a close interaction to hide the modal again.

This method mimics a lightbox effect entirely within Webflow, without any third-party code.

Rate this answer

Other Webflow Questions