Learning Flexbox & I don't understand why flex property is behaving the way it is. As I understand it, flex is simply shorthand for flex-grow, flex-shrink, and flex-basis with the last two being optional.
In my example below, I expected the same result using flex-grow vs flex with just the first value defined. I am getting different results but I don't understand why. The results in the first container is what I was expecting in both. Seems so straight forward I don't know what I am missing - shorthand properties don't work the way I am understanding them? Appreciate any help.
.container {
height: 200px;
width: 100%;
background: lightgray;
margin: 20px auto;
display: flex;
align-items: center;
}
.item {
height: 50px;
width: 300px;
align-items: flex-end;
}
.item1 {
border: 1px solid red;
flex-grow: 0;
}
.item2 {
border: 1px solid green;
flex-grow: 1;
}
.item3 {
border: 1px solid red;
flex: 0;
}
.item4 {
border: 1px solid green;
flex: 1;
}
<div class="container">
<div class="item item1"></div>
<div class="item item2"></div>
</div>
<div class="container">
<div class="item item3"></div>
<div class="item item4"></div>
</div>