flex-shrink

by Lingzhen Yang

HTML

<div class="outer">
<div class='div1'>1</div>
<div class='div2'>2</div>
<div class="div3">3</div>
</div>

CSS

.outer {
  width: 500px;
  display: flex;
}
.outer div {
  height: 80px;
}

.div1 {
  flex: 1 1 100px;
  background: red;
}
.div2 {
  flex: 1 2 200px;
  background: yellow;
}
.div3 {
  flex: 1 3 300px;
  background: green;
}

JavaScript

/*
div1 width = 100 - 100/1400*100 = 92.86

div2 width = 200 - 400/1400*100 = 171.42

div3 width = 300 - 900/1400*100 = 235.72
*/