Community forum for knowledge and support

Updated 2 months ago

Grid layout issue with flex and buttons displaying at bottom of cells in safari

At a glance

Hey folks!

I am having an issue with a grid and flex displaying properly in Safari and I can't pinpoint the problem or find a fix for this bug (if it's a bug).

Here's the issue: I would like the "learn more" and "get to know us" buttons to display at the bottom of each "cell" of the table. Picture 1 is how I would like it to look.

I have a flex container set to "space between" and a height of 100% (picture 2) nested inside of a grid set to auto height (picture 3) which is nested inside another grid also set to auto height (picture 4).

This setup doesn't have an issue in Chrome or Firefox, but when viewing in Safari, the buttons spill outside of the container, and things aren't scaling right (picture 5).

Does anyone have an idea of what's going on?

Attachments
image.png
image.png
image.png
image.png
image.png
J
J
2 comments

Going to go ahead and take a stab at helping you out here with ChatGPT:

Based on your description and the images you uploaded, it seems that the issue you're experiencing is related to how Safari renders the flexbox and grid settings in your Webflow project. Let's go over a few troubleshooting steps to address the issue of buttons spilling outside the container in Safari, which might be caused by Safari's differences in how it interprets CSS properties like flexbox and grid.

Common Issues with Safari and Flex/Grid Layouts:

  1. Flexbox 100% Height Issue: Safari sometimes struggles with flex containers having a height of 100%. This can cause content to overflow or not align properly within the parent container.
  2. Grid Auto Height Bug: In Safari, auto height within grid layouts can sometimes behave inconsistently, especially when combined with nested flexboxes. This may cause elements like buttons to overflow their intended container.
Steps to Fix the Issue:
1. Ensure Parent Containers Have Explicit Height Settings
  • Safari often requires explicit heights to properly calculate the layout. While Chrome and Firefox handle "100%" or "auto" in flexible contexts, Safari may not.
Solution: Set an explicit min-height on the parent grid and flex containers. For example:
css


.grid-container {
  min-height: 100vh; /* Or an appropriate height based on your layout */
}

.flex-container {
  min-height: 100%;
}
2. Fix Flexbox Height Issue in Safari
  • Flexbox elements may not scale as expected in Safari if the container’s height is not fully defined.
Solution: Use a fallback for height: 100% in flex containers:
css


.flex-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: auto; /* Set fallback */
  height: 100%; /* Target full height for other browsers */
}
3. Webkit Specific CSS Tweaks
  • You might need to add a specific rule for Safari using -webkit- prefixes to ensure proper rendering.
Solution: Add the following rule to ensure height is handled properly in Safari:
css


.flex-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
}
4. Use align-self or margin-top: auto for the Buttons
  • If your goal is to position the buttons at the bottom of the container, consider using margin-top: auto or align-self: flex-end for the button elements.
Solution: Apply this CSS to the button containers:
css


.button-container {
  margin-top: auto; /* Push the button to the bottom */
}
5. Ensure Grid's Auto Layout is Working
  • If you're using auto for grid heights, try setting an explicit height for grid items in Safari.
Solution: Set an explicit height for grid items:
css


.grid-item {
  min-height: 100%;
}
Final Recommendation:
In your Webflow project, ensure that each parent grid container, flexbox container, and the button element itself have appropriately defined heights and alignment. Safari tends to miscalculate height if any part of the layout is ambiguous (like using auto or 100% without a parent height).

ChatGPT 4.0 and the newset ChatGPT 01-mini diagnose 90% of the issues I face. I don't have the ability of elaborating my issues as well as you did though! Let me know if this helps.

Thanks for the help! I’ll keep digging on this issue and try these things

Add a reply
Sign up and join the conversation on Slack