<div id="app">
  <div class="header">
    <h2>property: {{key}}</h2>
    <div class="flex-layout flex-center">
      <label for="volume">容器尺寸:</label>
      <input
        type="range"
        id="volume"
        name="volume"
        min="380"
        max="550"
        style="margin: 0 20px"
        v-model="size"
      />
      <div>{{size}}</div>
    </div>
  </div>

  <div class="container">
    <div
      class="flex-container"
      :style="{height: size + 'px',width: size + 'px',}"
    >
      <div
        v-for="(item) in values"
        class="flex-item"
        :style="`${key}: ${item}`"
      >
        {{item}}
      </div>
    </div>
    <div
      class="flex-container"
      :style="{height: size + 'px',width: size + 'px', flexDirection: 'column'}"
    >
      <div
        v-for="(item) in values"
        class="flex-item"
        :style="`${key}: ${item};`"
      >
        {{item}}
      </div>
    </div>
  </div>
</div>
@default-color: fade(#1f2d3d, 70%);

@container-width: auto;
@flex-container-width: 520px;
@flex-container-height: 520px;
@flex-container-padding: 0;

// @flex-item-size: 80px;
@flex-item-width: 80px;
@flex-item-height: 80px;
@flex-item-margin: 12px;
@flex-item-font-size: 24px;

// @flex-item-height-1: 30px;
// @flex-item-height-2: 80px;
// @flex-item-height-3: 50px;
// @flex-item-height-4: 140px;
// @flex-item-height-5: 80px;

body {
  margin: 0;
}

button {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 15px;
  color: rgb(17, 85, 204);
  border-radius: 500px;
  bottom: 16px;
  cursor: pointer;
  justify-content: center;
  min-width: 32px;
  background-color: rgb(255, 255, 255);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 1px 2px rgba(0, 0, 0, 0.23);

  & + & {
    margin-left: 12px;
  }

  &.disabled {
    color: #bbb;
    box-shadow: none;
    cursor: auto;
  }
}

// #app {
//   overflow: auto;
// }

.flex-layout {
  display: flex;
}

.flex-center {
  justify-content: center;
  align-items: center;
}

.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: @container-width;
  max-width: 1200px;
  margin: auto;
  text-align: center;
  color: @default-color;
}

.header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 60px;
  padding: 0 20px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
  background: #fff;
  box-sizing: border-box;
}

.flex-container {
  display: flex;
  // flex-wrap: wrap;
  width: @flex-container-width;
  height: @flex-container-height;
  padding: @flex-container-padding;
  margin: 20px;
  background: fade(#3a506b, 70%);

  & + & {
    margin-top: 20px;
  }
}

.flex-item {
  display: flex;
  justify-content: center;
  align-items: center;
  height: @flex-item-height;
  width: @flex-item-width;
  margin: @flex-item-margin;
  font-size: @flex-item-font-size;
  transition: all 0.3s;

  &:nth-child(5n + 1) {
    background: #247ba0;
    color: fade(#fff, 70%);
  }
  &:nth-child(5n + 2) {
    background: #70c1b3;
  }
  &:nth-child(5n + 3) {
    background: #b2dbbf;
  }
  &:nth-child(5n + 4) {
    background: #f3ffbd;
  }
  &:nth-child(5n + 5) {
    background: #ff1654;
    color: fade(#fff, 70%);
  }
}

.line {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 50px auto 20px;
  width: @container-width;

  &:before {
    content: "";
    position: absolute;
    border-top: 2px solid @default-color;
    left: 0;
    right: 0;
    top: 16px;
    margin: auto;
    border-radius: 10px;
  }

  span {
    position: relative;
    display: inline;
    padding: 0 16px;
    background: #fff;
    font-size: 24px;
  }
}

.tips {
  text-align: left;
  margin: 30px 0;
  padding: 10px;
  border: 1px solid #ccc;
}

.w120 {
  width: 140px;
}

.h120 {
    height: 140px;
  font-size: 16px;
}
View Compiled
const property = 'flex-shrink';
const values = [0, 1, 2, 1, 0]

new Vue({
  el: '#app',
  data: {
    key: property,
    values: [...values],
    curIdx: 2,
    size: 520
  },
  methods: {
    changeSelect(e) {
      this.curIdx = e.target.value;
    },
    increase() {
      this.$set(this.values, this.curIdx, this.values[this.curIdx] + 1);
    },
    decrease() {
      const val = this.values[this.curIdx];
      if (!val) return;

      this.$set(this.values, this.curIdx, this.values[this.curIdx] - 1);
    },
    reset() {
      this.values = [...values]
    }
    
  }
})

View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdn.jsdelivr.net/npm/vue/dist/vue.js