I have a flex (column) container (.parent
) with two elements inside it (.row-1
, .row-2
). The first element .row-1
has a fixed height and flex-shrink
equals to 1. The second row .row-2
has a flex-grow
set to 1. Additionally, the second row has a child element with height equals to 100%. The expected behavior is that the child element (.child
) becomes the same height as its parent (i.e., .row-2
), which it does in Chrome and Firefox. However, in Safari the child element .child
has a height of 0 instead. Am I missing something here?
Here is the code I have:
<!DOCTYPE html>
<html lang="en">
<head>
<style>
* {
margin: 0;
padding: 0;
}
.parent {
display: flex;
flex-direction: column;
background: red;
height: 100vh;
}
.row-1 {
flex-shrink: 1;
height: 40px;
background: green;
}
.row-2 {
flex-grow: 1;
background: yellow;
}
.child {
background: cyan;
height: 100%;
}
</style>
</head>
<body>
<div class="parent">
<div class="row-1"></div>
<div class="row-2">
<div class="child"></div>
</div>
</div>
</body>
</html>