<div id="app">
<div class="header">
<h2>property: {{key}}</h2>
<div class="flex-layout flex-center">
操作元素
<select
:value="curIdx"
style="margin: 0 20px 0px 8px;"
@change="changeSelect"
>
<option v-for="(item, idx) in values" :value="idx">{{idx+1}}</option>
</select>
<button @click="increase">增加 {{key}}</button>
<button @click="decrease">
减少 {{key}}
</button>
<button @click="reset">重置</button>
</div>
</div>
<div class="container">
<div class="flex-container" style="flex:1">
<div
v-for="(item, idx) in values"
:class="['flex-item', {active: curIdx == idx}]"
:style="`${key}: ${item}`"
>
Item {{idx+1}}<br />
order: {{item}}
</div>
</div>
<div class="flex-container flex-container-column">
<div
v-for="(item,idx) in values"
:class="['flex-item', {active: curIdx === idx}]"
:style="`${key}: ${item};`"
>
item {{idx+1}}<br />
order: {{item}}
</div>
</div>
</div>
</div>
@default-color: fade(#1f2d3d, 70%);
@container-width: auto;
@flex-container-width: auto;
@flex-container-height: auto;
@flex-container-padding: 0;
@flex-item-size: 80px;
@flex-item-width: 110px;
@flex-item-height: 110px;
@flex-item-margin: 12px 0 12px 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);
border: none;
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: space-between;
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: 10px;
background: fade(#3a506b, 70%);
& + & {
margin-left: 0;
}
}
.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;
&.active {
outline: rgb(5,93,252) auto 5px;
}
&: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;
}
.flex-container.flex-container-column {
flex-direction: column;
width: auto;
height: auto;
.flex-item {
margin-right: 12px;
}
}
View Compiled
const property = 'order';
const values = [0, 0, 0, 0, 0]
new Vue({
el: '#app',
data: {
key: property,
values: [values],
curIdx: 2,
},
methods: {
changeSelect(e) {
this.curIdx = e.target.value;
},
increase() {
this.$set(this.values, this.curIdx, this.values[this.curIdx] + 1);
},
decrease() {
this.$set(this.values, this.curIdx, this.values[this.curIdx] - 1);
},
reset() {
this.values = [values]
}
}
})
View Compiled
This Pen doesn't use any external CSS resources.