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;.
html code
<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

Popular posts from this blog

ES6 : 5 Prevent Object Mutation

ES6: 1 Explore Differences Between the var and let Keywords

CSS Grid: Reduce Repetition Using the repeat Function