CodexBloom - Programming Q&A Platform

CSS Grid Items Not Aligning as Expected in Safari - Unexpected Gaps

👀 Views: 11 đŸ’Ŧ Answers: 1 📅 Created: 2025-08-22
css css-grid safari layout CSS

I've been struggling with this for a few days now and could really use some help. I am experiencing an scenario with my CSS Grid layout where items are not aligning properly in Safari, leading to unexpected gaps between them. The same layout works perfectly in Chrome and Firefox. I'm using the following CSS for my grid layout: ```css .container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; } .item { background: #4CAF50; height: 100px; display: flex; align-items: center; justify-content: center; } ``` And my HTML structure looks like this: ```html <div class="container"> <div class="item">1</div> <div class="item">2</div> <div class="item">3</div> <div class="item">4</div> <div class="item">5</div> <div class="item">6</div> </div> ``` When viewed in Safari, an unexpected vertical gap appears between the second and third items, while the rest align perfectly. I have already tried adding `box-sizing: border-box;` to the `.item` class, but it did not resolve the scenario. Additionally, I ensured that all vendor prefixes are in place, using tools like Autoprefixer. I also verified that my Safari version is up to date (version 16.0). I would appreciate any insights into why this might be happening or suggestions on how to fix these gaps specifically in Safari. Is this a known scenario with Safari's rendering of CSS Grid, or could it be related to my specific implementation? Has anyone else encountered this?