-
Notifications
You must be signed in to change notification settings - Fork 0
/
_grid.scss
95 lines (77 loc) · 1.77 KB
/
_grid.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@charset "utf-8";
/*--------------grid-------------*/
// 简易版网格系统,命名参考bootstrap
$gridSize:xs sm md lg;
$breakPoint: (768px 750px) (992px 900px) (1200px 1170px) !default;
$colNum: 12 !default;
$gutter: 15px !default;
.container {
width: 100%;
margin-left: auto;
margin-right: auto;
padding:$gutter;
@include clearfix;
}
.container-fluid {
width: 100%;
}
.row {
@include clearfix;
}
// 媒体查询
%col {
position: relative;
min-height: 1px;
}
@for $i from 1 through $colNum {
@for $j from 1 through length($gridSize) {
.col-#{nth($gridSize,$j)}-#{$i}{
@extend %col;
padding: $gutter;
}
}
}
@each $s in $gridSize {
@if (index($gridSize,$s) == 1){
.hide-xs {
display: none;
}
}@else {
.show-#{$s} {
display: none;
}
}
}
// xs
@for $i from 1 through $colNum {
.col-#{nth($gridSize,1)}-#{$i}{
width: percentage($i/$colNum);
float: left;
}
}
// sm md lg
@for $i from 1 through length($breakPoint) {
@media screen and (min-width: nth(nth($breakPoint,$i),1)) {
.container {
width: nth(nth($breakPoint,$i),2);
margin-left: auto;
margin-right: auto;
}
@for $j from 1 through $colNum {
.col-#{nth($gridSize,$i+1)}-#{$j}{
width: percentage($j/$colNum);
float: left;
}
}
}
// 显示和隐藏
@media screen and (max-width: nth(nth($breakPoint,$i),1)){
.hide-#{nth($gridSize,$i+1)} {
display: none !important;
}
.show-#{nth($gridSize,$i+1)} {
display: block ;
}
}
}
/*--------------end grid-------------*/