mdeschaetzen Posted November 26 Posted November 26 Site URL: https://www.morganedeschaetzen.com/ Hi everyone, I use gallery section on my portfolio; masonry grids with three columns, and would like the mobile view to match the desktop view exactly. I have tried several CSS codes found on the forum but none work to match both views perfectly. The following code is the closest I could get to achieving the same layout on mobile: /* Masonry to grid mobile */ @media screen and (max-width:768px) { .gallery-masonry-wrapper.gallery-masonry-list--ready { height: auto !important; display: grid; grid-template-columns: repeat(3,1fr) !important; grid-column-gap: 10px; grid-row-gap: 10px; } figure.gallery-masonry-item { position: relative !important; width: 100% !important; transform: unset !important; } .gallery-masonry-item-wrapper { height: 100% !important; width: 100% !important; } } But the proportions are off (it's cropping both end of the gallery) and the images aren't fitting together as they do on desktop, the spacing is different too. I've attached screenshots so you can see both versions. Anyone here knows how to fix this?
tuanphan Posted Thursday at 08:53 AM Posted Thursday at 08:53 AM @mdeschaetzen Remove your code & use this new code @media only screen and (max-width: 767px) { .gallery-masonry .gallery-masonry-wrapper { columns: 3; column-gap: 0; height: auto!important; display: block!important; padding: 0px; } .gallery-masonry-item-wrapper { height: auto!important; } .gallery-masonry-item { position: relative!important; transform: none!important; width: 100%!important; display: block; padding: 1.5px!important; box-sizing: border-box; } .gallery-masonry .gallery-masonry-item img { height: 100%!important; width: 100%!important; } } Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
mdeschaetzen Posted Thursday at 09:59 AM Author Posted Thursday at 09:59 AM Hey @tuanphan thank you for your help, this is much better. Although it changes the order in which the images are presented (see screenshot) , is there any additional code I could use to keep the same arrangement?
tuanphan Posted Sunday at 03:08 AM Posted Sunday at 03:08 AM I don't have other code to fix this problem. Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment