Open andypinet opened 7 years ago
现在手机都支持flexbox了 会更加简单了
<div class="grid"> <!-- 4 columns with padding -->
<div class="grid-item is xs-3-of-12">
1- lorem ipsum<br>Lorem Elsass ipsum lacus leverwurscht Wurschtsalad mamsell Gal.
</div>
<div class="grid-item is xs-3-of-12">
2- lorem ipsum Hopla choucroute !
</div>
<div class="grid-item is xs-3-of-12">
3- lorem ipsum<br>condimentum Verdammi ch'ai ac réchime météor barapli s'guelt quam, non Christkindelsmärik blottkopf, Carola tellus rucksack vielmols, Gal !
</div>
<div class="grid-item is xs-3-of-12">
4- lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
</div>
<div class="grid-item is xs-3-of-12">
5- lorem ipsum<br>Yoo ch'ai lu dans les DNA que le Racing a encore perdu contre Oberschaeffolsheim. Verdammi
</div>
<div class="grid-item is xs-3-of-12">
6- lorem ipsum<br>Lorem Elsass ipsum lacus leverwurscht Wurschtsalad mamsell Gal.
</div>
<div class="grid-item is xs-3-of-12" style="margin-left: auto;">
7- simple "offset" with <br><code>margin-left: auto</code>
</div>
</div>
$media: "xs";
$rownum: 12;
$gutter: 10px;
.grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin-left: -$gutter;
/* Inline-block fallback */
letter-spacing: -0.31em;
text-rendering: optimizespeed;
}
.grid > .grid-item {
flex: 0 0 auto;
display: block; /* IE fix */
margin-left: $gutter;
/* Inline-block fallback */
display: inline-block;
vertical-align: top;
letter-spacing: normal;
text-rendering: auto;
}
@for $i from 1 through $rownum {
&.is.#{$media}-#{$i}-of-#{$rownum} {
width: calc(#{1/$rownum*100%*$i} - #{$gutter});
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
}
无论什么布局 我们都会注意到其实 很多情况下精确的定义可能更好