Webflow sync, pageviews & more.
NEW

How can I create a slider for a before/after image view in Webflow? Is there a better way to showcase comparison photos for optimal mobile view?

TL;DR
  • Use a third-party embed (e.g., JuxtaposeJS) or custom code with layered images and a range slider to create the before/after effect.
  • For mobile-friendly design, ensure images are responsive and consider using a toggle-based image comparison for better touch interaction.

To create a before/after image slider in Webflow, you’ll need to use custom code or a third-party integration, as Webflow does not offer a native before/after slider component. Here's how you can do it effectively and make it mobile-friendly.

1. Use a Third-Party Before/After Slider

  • Recommended Tool: Use the TwentyTwenty jQuery plugin or an embed from a tool like JuxtaposeJS or Compare Image Slider by Elfsight.
  • How to Add:
  • Add an Embed Element from the Add panel.
  • Paste the third-party embed code (you'll need to include CSS and JavaScript manually).
  • Inside the embed, place two images: the before and after versions, following the plugin syntax.
  • Mobile Optimization:
  • Ensure both images are the same size and are set to 100% width with auto height.
  • Add loading="lazy" to images to improve performance on mobile.

2. Use Webflow with Custom Code (Advanced)

  • Create a Div Block with relative position.
  • Place two Image Blocks inside it: set one as absolute and layered over the other.
  • Add an Input Range Slider below or on top (via absolute positioning).
  • Use custom JavaScript to link the slider to the width of the top image, dynamically revealing more or less of the top (after) image.
  • Ensure the script responds to window resizing for responsive behavior.

3. Alternative: Stacked Comparison with Toggle

For simpler setups or better mobile performance:

  • Use two image elements, one above the other.
  • Add a toggle button (e.g., “See Before / See After”) using Webflow Interactions.
  • When toggled, use opacity or display changes to show/hide the respective image.
  • This ensures better responsivity on mobile without requiring dragging/slider gestures.

4. Tips for Mobile Optimization

  • Keep image file sizes small but high-quality using compression tools (e.g., TinyPNG).
  • Ensure the slider or image container is responsive with 100% width and maximum width constraints.
  • Test gestures on mobile—many users have trouble with small draggable sliders.

Summary

To create a before/after image slider in Webflow, use a third-party embed like JuxtaposeJS or custom code involving layered images and a JavaScript-powered range slider. For optimal mobile experience, consider a toggle-based comparison that’s simpler to use and more touch-friendly.

Rate this answer

Other Webflow Questions