<div id="app">
<div class="header">
<h2>property: <code>{{key}}</code></h2>
<div class="operation-area"></div>
</div>
<div class="container">
<div class="content-container">
<div class="subcontainer" style="margin-top: 20px">
<div class="flex-container">
<div
v-for="(item, idx) in styles"
class="flex-item"
:style="item"
v-html="formatStyles(item)"
></div>
</div>
<div class="flex-container" style="flex-direction: column">
<div
v-for="(item, idx) in styles"
class="flex-item"
:style="item"
v-html="formatStyles(item)"
></div>
</div>
</div>
</div>
</div>
</div>
@default-color: fade(#1f2d3d, 70%);
@container-width: 1000px;
@flex-container-width: 520px;
@flex-container-height: auto;
@flex-container-padding: 0;
@flex-item-size: 150px;
@flex-item-margin: 12px;
@flex-item-font-size: 18px;
// @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);
+ button {
margin-left: 12px;
}
}
#app {
overflow: auto;
}
.flex-layout {
display: flex;
}
.container {
overflow: auto;
padding: 0 20px;
}
.content-container {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
width: @container-width;
margin: auto;
text-align: center;
color: @default-color;
}
.subcontainer {
width: 100%;
}
.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: 100%;
height: @flex-container-height;
padding: @flex-container-padding;
margin: auto;
background: fade(#3a506b, 70%);
& + & {
margin-top: 20px;
}
}
.flex-item {
display: flex;
justify-content: center;
align-items: center;
height: @flex-item-size;
// width: @flex-item-size;
margin: @flex-item-margin;
font-size: @flex-item-font-size;
&: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;
}
&-content {
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;
}
View Compiled
const defaultWidth = 150;
const styles = [
`width: ${defaultWidth}px`,
`width: ${defaultWidth}px; flex-basis: 200px`,
"width: auto",
`width: ${defaultWidth}px; flex-basis: auto`,
`width: ${defaultWidth}px; flex-basis: 0`,
`width: auto; flex-basis: 0`,
]
const property = 'flex-basis';
new Vue({
el: '#app',
data: {
key: property,
styles
},
methods: {
formatStyles(styles) {
return styles.split(';')
.map(item => {
return `<code>${item};<code/>`
}).join('<br />')
}
}
})
View Compiled
This Pen doesn't use any external CSS resources.