Premium
Snippet

Variable Width Slider + Contained Content Using PowerPack Image Carousel

This is a premium 
Snippet

To view the whole 
Snippet
, subscribe to SnippetNest ($99/year) and unlock access to all my premium
Snippet
s OR get access to just this 
Snippet
for only $!

Creating a full-width image carousel that maintains perfect alignment with your contained content can be tricky, especially when you want variable-width slides that adapt to your image dimensions. Most carousels are designed to have uniform slide widths, but unless you have full control over the code, achieving variable widths while maintaining proper alignment is challenging.

This snippet transforms a PowerPack Image Carousel into a responsive, full-width slider where the first image always aligns with your page content, regardless of screen size. What makes this particularly useful is that your content above and below the carousel can remain within your site’s container width, while the carousel itself breaks out to full width with edge slides extending off-screen for visual hinting and stylistic effect. AND the “first” slide aligns with the content above it too!

Here is an example of what that can look like:

How it Works

This code intercepts PowerPack Image Carousel instances (identified by the variable-width-slider class or whatever class you choose) and modifies their Swiper configuration. It calculates the precise offset needed to align the first slide with your Beaver Builder row content, taking into account different screen sizes and responsive breakpoints. The solution works by:

  • Calculating the exact offset based on your Beaver Builder row width and viewport size
  • Modifying both existing carousels and new ones that get added dynamically
  • Using variable slide widths that adapt to image dimensions
  • Maintaining smooth scrolling with free mode enabled

Important: This code requires the CSS Variables for Beaver Builder Global Settings snippet to access the row width and module margin settings needed for the offset calculations.

On to the Code!

JavaScript

Add this JavaScript to your site (either in the BB global or layout JS or your theme’s JS file):

Blurred JavaScript code block

Table of Contents

  • How it Works
  • On to the Code!
    • JavaScript
    • CSS
  • Example Use Case
  • Troubleshooting

Language

JS

Purchase this
Snippet

Get access to this
Snippet
for just $

Purchase this snippet

Purchase Snippet + User Registration
Apply Coupon
Price: $10.00

Sign up for SnippetNest

Get access to everything for $99/year