我不清楚你想要发生什么......但是作为首发,这又如何呢?
https://codepen.io/sheriffderek/pen/a88b66fa934e4abbd38e054a45d3f2ff
标记事物列表......这就是你所拥有的。
<ul class='thing-list'>
<li class='thing one'>
<a href='' class='link'>.</a>
</li>
<li class='thing two'></li>
<li class='thing three'></li>
<li class='thing four'></li>
<li class='thing five'></li>
<li class='thing six'></li>
<li class='thing seven'></li>
<li class='thing eight'></li>
</ul>
我强烈建议您在 CSS 中使用 Stylus - 但编译后的 CSS 在下面
/* apply a natural box layout model to all elements, but allowing components to change */
html
box-sizing: border-box
*, *:before, *:after
box-sizing: inherit
.thing-list
display: flex
flex-direction: row
flex-wrap: wrap
.thing
min-height: 90px
flex-basis: (1/12)*100%
&.one
background: hsl(0,100%,75%)
&.two
flex-basis: (2/12)*100%
background: hsl(20,100%,60%)
&.three
background: hsl(40,100%,75%)
&.four
background: hsl(60,100%,60%)
&.five
background: hsl(80,100%,65%)
&.six
flex-basis: (2/12)*100%
background: hsl(150,100%,60%)
&.seven
background: hsl(260,100%,75%)
&.eight
flex-basis: (3/12)*100%
background: hsl(0,100%,80%)
.link
display: block
color: inherit
text-decoration: none
width: 100%
min-height: 90px
// i'd prabably color the link - not the li
@media (min-width: 600px)
.thing
flex-basis: (2/12)*100%
&.two
flex-basis: (4/12)*100%
&.six
flex-basis: (4/12)*100%
&.eight
flex-basis: (6/12)*100%
CSS
/* apply a natural box layout model to all elements, but allowing components to change */
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.thing-list {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.thing-list .thing {
min-height: 90px;
-ms-flex-preferred-size: 8.333333333333332%;
flex-basis: 8.333333333333332%;
}
.thing-list .thing.one {
background: #ff8080;
}
.thing-list .thing.two {
-ms-flex-preferred-size: 16.666666666666664%;
flex-basis: 16.666666666666664%;
background: #f73;
}
.thing-list .thing.three {
background: #ffd480;
}
.thing-list .thing.four {
background: #ff3;
}
.thing-list .thing.five {
background: #c3ff4d;
}
.thing-list .thing.six {
-ms-flex-preferred-size: 16.666666666666664%;
flex-basis: 16.666666666666664%;
background: #3f9;
}
.thing-list .thing.seven {
background: #aa80ff;
}
.thing-list .thing.eight {
-ms-flex-preferred-size: 25%;
flex-basis: 25%;
background: #f99;
}
.thing-list .thing .link {
display: block;
color: inherit;
text-decoration: none;
width: 100%;
min-height: 90px;
}
@media (min-width: 600px) {
.thing-list .thing {
-ms-flex-preferred-size: 16.666666666666664%;
flex-basis: 16.666666666666664%;
}
.thing-list .thing.two {
-ms-flex-preferred-size: 33.33333333333333%;
flex-basis: 33.33333333333333%;
}
.thing-list .thing.six {
-ms-flex-preferred-size: 33.33333333333333%;
flex-basis: 33.33333333333333%;
}
.thing-list .thing.eight {
-ms-flex-preferred-size: 50%;
flex-basis: 50%;
}
}