CSS Grid Layout Causing Unwanted Gaps Between Items on Mobile Devices - Need guide with Media Queries
I'm trying to figure out I'm deploying to production and I'm building a feature where I'm trying to configure I'm writing unit tests and I've been struggling with this for a few days now and could really use some help... I'm experiencing an scenario with a CSS Grid layout where, when viewed on mobile devices, there are unwanted gaps between grid items that don't appear on larger screens. I'm using the following CSS for my grid: ```css .container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; } .item { background: lightblue; padding: 20px; text-align: center; } ``` The layout looks perfect on desktop, but when I switch to a mobile viewport, I applied a media query to adjust the grid layout like this: ```css @media (max-width: 768px) { .container { grid-template-columns: repeat(2, 1fr); gap: 5px; } } ``` Despite changing the column count and gap, there are still extra spaces appearing between items on certain mobile browsers, particularly Safari on iOS. I checked the computed styles and the grid properties seem to be applied correctly. I’ve also tried using `box-sizing: border-box;` but that didn’t resolve the scenario either. Has anyone faced this question and found a solution? Any insights on how to properly manage grid gaps across different screen sizes would be greatly appreciated. Thank you! My development environment is macOS. Is there a better approach? I'm working in a Ubuntu 22.04 environment. This issue appeared after updating to Css latest. For reference, this is a production REST API. Any ideas what could be causing this? Thanks for taking the time to read this!