siwi-layout
v1.0.3
Published
layout for siwi ui
Downloads
58
Readme
#Siwi Layout
Flex弹性布局 16 栅格
变量
@css-namespace : sw;
@css-prefix : sw-;
@row-prefix : row-;
@row : row;
@col-prefix : col-;
@col : col;
// Layout and Grid
@grid-columns : 16;
@grid-gutter-width : 0;
// Extra small screen / phone
@screen-xs : 480px;
@screen-xs-min : @screen-xs;
@screen-xs-max : (@screen-xs-min - 1);
// Small screen / tablet
@screen-sm : 768px;
@screen-sm-min : @screen-sm;
@screen-sm-max : (@screen-sm-min - 1);
// Medium screen / desktop
@screen-md : 992px;
@screen-md-min : @screen-md;
@screen-md-max : (@screen-md-min - 1);
// Large screen / wide desktop
@screen-lg : 1200px;
@screen-lg-min : @screen-lg;
@screen-lg-max : (@screen-lg-min - 1);
混合
.make-row(@gutter: @grid-gutter-width) {
position: relative;
margin-left: (@gutter / -2);
margin-right: (@gutter / -2);
height: auto;
.clearfix;
}
.loop-col(@class) {
.col(@index) {
@item: ~".@{col-prefix}@{class}@{index}";
.col((@index + 1), @item);
}
.col(@index, @list) when (@index =< @grid-columns) {
@item: ~".@{col-prefix}@{class}@{index}";
.col((@index + 1), ~"@{list}, @{item}");
}
.col(@index, @list) when (@index > @grid-columns) {
@{list} {
float: left;
flex: 0 0 auto;
display: block;
}
}
.col(1);
}
.loop-pull(@index) when (@index > 0) {
.pull-@{index} {
right: percentage((@index / @grid-columns));
}
.loop-pull(@index - 1);
}
.loop-push(@index) when (@index > 0) {
.push-@{index} {
left: percentage((@index / @grid-columns));
}
.loop-push(@index - 1);
}
.loop-offset(@index) when (@index > 0) {
.offset-@{index} {
margin-left: percentage((@index / @grid-columns));
}
.loop-offset(@index - 1);
}
.loop-order(@index) when (@index > 0) {
.order-@{index} {
order: @index;
}
.loop-order(@index - 1);
}
.loop-grid-columns(@index, @class) when (@index > 0) {
.@{col-prefix}@{class}@{index} {
width: percentage((@index / @grid-columns));
}
.loop-grid-columns((@index - 1), @class);
}
.loop-grid-columns(@index, @class) when (@index =0) {
.@{col-prefix}@{class}@{index} {
display: none;
}
}
.make-grid(@class: ~'') {
.loop-col(@class);
.loop-grid-columns(@grid-columns, @class);
}
.make-pull-push-offset-order () {
.loop-pull(@grid-columns);
.loop-push(@grid-columns);
.loop-offset(@grid-columns);
.loop-order(@grid-columns);
}
.clearfix() {
zoom: 1;
&:before,
&:after {
content: "";
display: table;
}
&:after {
clear: both;
visibility: hidden;
font-size: 0;
height: 0;
}
}
自定义
可以通过修变量达到自定义的效果