Show 2 Images at a Time in the Gallery Module Slide Layout

Written by Dan Mossop

The Divi Theme's gallery module has two layout options: grid and slider. When the slider layout is active, the gallery shows one image at a time (and you can move from one to the next with arrow buttons). If you'd like to have the gallery slider display two images at a time, this post explains how to do it.

First, here's an example of the effect we're aiming for – one gallery module in slider layout displaying two images at a time:

Show 2 Gallery Images at a Time using CSS

One way to get 2 gallery images showing at a time is to force the currently displayed slide to take up only 50% of the available width and then force the next slide to be displayed in the remaining 50% space.

To do this using CSS, first set "Gallery Settings > Advanced > CSS ID & Classes > CSS Class" to:

gallery-two-at-a-time

Then add this CSS to your site:

/* Display two gallery images */
@media only screen and (min-width: 981px) {
	
	/* Set images to 50% width */
	.gallery-two-at-a-time .et_pb_gallery_item {
		max-width: 50%;
	}
	
	/* Force display of the image after the currently displayed one */
	.gallery-two-at-a-time .et-pb-active-slide + .et_pb_gallery_item {
		display: block !important; 
		opacity: 1 !important; 
		z-index: 1 !important;
		left: 50%;
	}
	
	/* Display the first image at the end */
	.gallery-two-at-a-time .et_pb_gallery_item:first-child:not(.et-pb-active-slide) {
		display: block !important; 
		opacity: 1 !important; 
		z-index: 0 !important;
		left: 50%;
	}
}

We may earn a commission when you visit links on our website.

Showcase Your Work Beautifully with Divi Gallery Booster

Enhance the visual appeal of your gallery modules with Divi Gallery Booster. This tool helps you style your galleries effortlessly, perfect for showcasing multiple images seamlessly. Save time and create stunning displays to captivate your audience.

Latest Posts

Customize Lightbox Title Styling in the Divi Gallery Module

Adjust the appearance of the lightbox title that appears when visitors open images from a Divi Gallery to align with your brand and improve readability. Refining the title’s color, size, and weight enhances visual hierarchy, accessibility, and overall polish. In this...

Center the Lightbox Image Count in the Divi Gallery Module

Centering the image count in a gallery lightbox creates a cleaner, more balanced presentation and makes it easier for visitors to see where they are in the image set. This simple visual tweak can enhance readability, especially with larger images and longer captions,...

Style the Divi Gallery Module Lightbox Image Count

Tailor the appearance of the image counter in the Divi Gallery module lightbox to match your brand and improve readability. By customizing the counter’s color and typography, you ensure it displays clearly and suits your design. In this guide we show you how to style...

Customize the Lightbox Image Background Color in the Divi Gallery

Control the color that appears behind your images when users open in the gallery lightbox, including support for semi-transparent hues. This helps improve contrast for transparent images, align the experience with your brand palette, and create a more polished viewing...

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

2 Comments

  1. Hey Dan, this is really a great tweak. I was looking for something like this to edit the gallery slider and make it look like a carousel slider. I tried to edit your css to show 3 images at a time but my skills seam to be too poor for that. Could you give me a hint possibly?

    Best regards and keep up the good work!

    Reply
    • Hey Robert, sorry I'm only just responding. I been playing around with this, but I don't think it's actually possible to modify the two images at a time CSS to work with three images. The reason is that CSS don't support rich enough logic to allow handling of the edge cases where we need to move the first and second slides to the end when the last one is active. I think a different approach will be needed, possibly using either flexbox's ordering or javascript to handle these edge cases. I'll try to spend some more time on this as soon as I can and will update here if I'm able to figure anything out. Cheers!

      Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.