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%;
	}
}

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.

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 *.

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

Latest Posts

Set Custom CSS IDs for Individual Divi Accordion Items

Assigning unique CSS IDs to specific Divi Accordion items allows for precise control over styling, targeting, and linking within your page content. This ability is particularly useful when you want to apply custom designs or create anchor links to particular accordion...

Enable Swipe Navigation in the Divi Gallery Lightbox

Enabling swipe navigation in the Divi Gallery module's lightbox allows users to seamlessly browse through gallery images by swiping left or right, creating a more interactive and mobile-friendly experience. This functionality can significantly improve user engagement...

Disable Slide-In Animation for Divi Gallery Grid Images

Control how images appear in your Divi Gallery module by toggling the slide-in animation effect for grid layouts. Disabling the slide-in animation allows gallery images to load instantly and appear statically, providing a faster and distraction-free browsing...

Control Image Count Display in Divi Gallery Lightbox

Displaying or hiding the image count in the Divi Gallery module’s lightbox can help customize the user experience, depending on whether you want to give visitors an indication of gallery progress or prefer a cleaner, distraction-free view. The ability to toggle this...

Hide Gallery Image Titles in the Divi Lightbox Overlay

Displaying image titles in the lightbox overlay of the Divi Gallery module can sometimes be distracting or unnecessary, depending on your website’s design and user experience goals. Hiding these titles creates a cleaner and more focused viewing experience for visitors...

Random Posts