misschaela Posted November 18, 2023 Share Posted November 18, 2023 (edited) Hi, I have a masonry gallery and I wanted 4 columns on a standard laptop (MacBook), 5 columns on larger screens (iMac) and 1 column on mobile. I already found code on how to change the amount of columns to 1 on mobile and added another piece of code now for 5 columns but it's not working it keeps going from 4 to 1 column instead of 5 once the dimensions are greater than the amount set. I was wondering if anyone knows why this is occurring. Any help would be greatly appreciated. Michaela Here is the code I have added (SS are also below): /* Masonry 5 items*/ @media screen and (min-width:1920px) { .gallery-masonry-wrapper.gallery-masonry-list--ready { height: auto !important; } figure.gallery-masonry-item { position: relative !important; width: 20% !important; transform: unset !important; } .gallery-masonry-item-wrapper { height: auto !important; } .gallery-masonry .gallery-masonry-item[data-loaded] img { width: 100% !important; } .gallery-masonry { padding-left: 1vw !important; padding-right: 1vw !important; } } /* Masonry one item on mobile */ @media screen and (max-width:640px) { .gallery-masonry-wrapper.gallery-masonry-list--ready { height: auto !important; } figure.gallery-masonry-item { position: relative !important; width: 100% !important; transform: unset !important; } .gallery-masonry-item-wrapper { height: auto !important; } .gallery-masonry .gallery-masonry-item[data-loaded] img { width: 100% !important; } .gallery-masonry { padding-left: 1vw !important; padding-right: 1vw !important; } } Edited November 18, 2023 by misschaela Change text Link to comment
tuanphan Posted November 20, 2023 Share Posted November 20, 2023 Use this code instead @media screen and (min-width:1920px) { .gallery-masonry .gallery-masonry-wrapper { columns: 5; 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; } } misschaela 1 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!) Link to comment
misschaela Posted December 4, 2023 Author Share Posted December 4, 2023 On 11/20/2023 at 2:46 AM, tuanphan said: Use this code instead Thank you, I've added this code and now it changes to 5 columns but the images in the second and third column are slightly lower and I'm not sure how to fix this. Also when decreasing the window width and then increasing again the images aren't in the last two columns. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment