Quantcast
Channel: Active questions tagged flexbox - Stack Overflow
Viewing all articles
Browse latest Browse all 1320

Safari places elements outside flex column

$
0
0

I have the following HTML and CSS:

.container {  display: flex;  min-height: 100vh;  flex-direction: column;  gap: 2px;}.header-nav,.footer-nav,.container {  padding: 4px;}.main-content {  display: flex;  flex: 1;  flex-direction: column;  border-radius: 1rem;  background-color: #F1F5F9;  padding: 6px;}.grid-content {  display: grid;  flex-grow: 1;  gap: 10px;  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));}.form-content {  display: flex;  flex-direction: column;  gap: 2px;}.flex-content {  flex: 1;}.button {  background-color: #1E3A8A;  padding: 4px;  color: #BFDBFE;}
<div class="container"><nav class="header-nav">Header navigation</nav><main class="main-content"><div class="grid-content"><form class="form-content"><div class="flex-content">          Main content form</div><button class="button">Button</button></form><aside>Aside</aside></div></main><nav class="footer-nav">Footer navigation</nav></div>

It's a full page app layout. It creates a header, a content area and a footer. In the content area there are two columns, one for the main content, one for aside. My aim is that the button is placed on the bottom of the page. Note the button on the reference image.

Firefox (and Chrome) - all good

reference image

Safari - issue

bug in Safari

In Safari the button is positioned outside the main content area.

Playgrounds

The optimal solution will not alter the markup too much. This is a web application with nested web components. I don't want to refactor template logic.

The markup works fine in Firefox (124) and Chrome but fails in Webkit (Safari 189). I have checked similar issues here, but I think this might be unique. I am hoping to be missing something obvious.

I have already tested:

  • Removing min-height: 100vh on the .container will fix the issue. But I want to the page to fill the viewport. height: 100% will not work either for my use case, since the content can be larger.
  • Removing the .grid-content (and the aside) also makes the issue go away. The grid is required to display navigation.
  • At a certain height the threshold jumps back into the desired position. Strange! Maybe the height calculation is not considering the outer header and footer.

Viewing all articles
Browse latest Browse all 1320

Trending Articles