Overlapping CSS flexbox items in Safari
The element is shrinking. You need to set the flex-shrink
property to 0
on the shrinking element.
main >div:first-child {
-webkit-flex: 0;
flex-shrink: 0;
}
While I can no longer replicate the issue of OP using Safari 14.0.2, I still observe in some cases where Safari would over-shrink elements that other browsers like Safari and Firefox do not.
Although setting flex-shrink: 0;
works, in some cases, we intend to use like flex: 0 1 15%
where we want shrinking to happen, but without the over-shrinking.
Workaround seems to work for me:
min-height: min-content
(or min-width
)
I also had a similar issue where flex box direction changed to column overlapped items on iPad. The issue was with the flex: 0 1 0;
property applied to child element. Give the base value auto. flex: 0 1 auto;
.parent{
display: flex;
flex-direction: column;
}
.parent .child{
flex: 0 1 auto;
}