.container {
display: flex;
justify-content: center;
align-items: center;
}
.flex-container > div {
flex:2;
}
The selector above has class name and tag name, therefore it's more specific than this selector:.search {
flex:4;
}
That's why the second selector has no effect in this example.
With more specific selector, like this:.flex-container .search {
flex:4;
}
the .search item will be twice as wide as the other flex items.flex
value, they will take the same space and will shrink and grow equally.container div {
flex: 1;
}
.flex-item:nth-child(1) {
flex:1;
}
The above flex
property is a shorthand of the following properties:.flex-item:nth-child(2) {
flex-grow:1;
flex-shrink:1;
flex-basis:0;
}
In the example, the first two elements have the same effect