CSS Flexbox: Use the flex Shorthand Property
There is a shortcut available to set several flex properties at once. The
flex-grow, flex-shrink, and flex-basis properties can all be set together by using the flex property.
For example,
flex: 1 0 10px; will set the item to flex-grow: 1;, flex-shrink: 0;, and flex-basis: 10px;.
The default property settings are
flex: 0 1 auto;.<style> #box-container { display: flex; height: 500px; } #box-1 { background-color: dodgerblue; flex:2 2 150px; height: 200px; } #box-2 { background-color: orangered; flex:1 1 150px; height: 200px; } </style> <div id="box-container"> <div id="box-1"></div> <div id="box-2"></div> </div>
Comments
Post a Comment