Jump to content

Change amount of columns of gallery grid according to screen size

Recommended Posts

Posted

Hi all,

I have a gallery section on my website in a masonry grid. In squarespace I set the amount of columns to 3. Per default the mobile version makes it into two columns, which is fine. However when checking the website on really large screens a three column grid seems too big, losing the overview of the gallery. I was therefor wondering if it's possible to tweak the website/write some code so that on large screens (let's say a resolution of more then 1920px), there will be 4 instead of the usual three columns. 

Thanks in advance! Blow a screenshot if the website as it is now. 

Thanks in advance!

Matthias

 

 

image.thumb.png.a7da8db4584a85ecf4eb40e105aaae4b.png

 

  • Replies 4
  • Views 1.2k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

@Matthias39682 Hi, Here's a code snippet to display 4 columns in your gallery section when the screen resolution is more than 1920px:

@media screen and (min-width:1921px) {
	figure.gallery-masonry-item img {
    	width: 100% !important;
	}
	.gallery-masonry-item-wrapper {
		height: auto !important;
	}
	figure.gallery-masonry-item {
		position: initial !important;
		float: left !important;
		display: block!important;
		width: 25% !important;
		transform: unset !important;
		padding-right: 3vw !important;
		padding-bottom: 3vw !important;
		box-sizing: border-box;
	}
}

Code works to display 4 columns. However, it changes the placements of the images in the gallery. 

If you want to place the images in different manner while using 4 columns, you can create a new section with the same gallery. Then with some basic CSS, we can display that galley only when screen resolution is more than 1920px.

Let me know how it goes.

 

Thanks!

Sam

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Posted

@Lesum, thanks again for your help!

I added the code and it almost seems to work but there is something wrong with the alignment of the images. The masonry grid is a bit flawed for the first three colums (the images are pushed into a more regular grid by adding white space between, see screenshot below). Is there any way to change this?

I understand your solution with two different galleries. However I suppose it also means that when we add projects to our portfolio (gallery), we have do to the process twice? It's an option worth considering, but for now I prefer not having control about the order of projects in the 4-column grid. At least when the allignment issue can be solved. 

Thanks so much for your help!

Kind regards, Matthias

 

image.thumb.png.f77dfacc056b8f8fe60adad85f4a3f83.png

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.