forked from weixin/mixins.less
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mixins-mobile.less
294 lines (261 loc) · 7.23 KB
/
mixins-mobile.less
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
//----------------------------
//
// mixins.less v0.1.5
// http://mixinsless.com/
// Reuse snippets & Cross-browser private properties snippets.
//----------------------------
// Border radius with the same argument
// -------------------------
.rounded(@radius: 3px) {
-webkit-border-radius:@radius;
border-radius:@radius;
-webkit-background-clip:padding-box;
background-clip:padding-box;
}
// Border radius with different arguments
// -------------------------
.border-radius(@topleft: 0, @topright: 0, @bottomright: 0, @bottomleft: 0) {
-webkit-border-top-left-radius:@topleft;
-webkit-border-top-right-radius:@topright;
-webkit-border-bottom-right-radius:@bottomright;
-webkit-border-bottom-left-radius:@bottomleft;
border-top-left-radius:@topleft;
border-top-right-radius:@topright;
border-bottom-right-radius:@bottomright;
border-bottom-left-radius:@bottomleft;
-webkit-background-clip:padding-box;
background-clip:padding-box;
}
// Background size
// -------------------------
.background-size(@size) {
-webkit-background-size:@size;
background-size:@size;
}
// Opacity
// -------------------------
.opacity(@opacity) {
opacity:@opacity;
}
// Appearance
// -------------------------
.appearance(@appearance:none) {
-webkit-appearance:@appearance;
appearance:@appearance;
}
// Gradient
// -------------------------
.gradient(@start: #000000, @stop: #FFFFFF) {
background:(@start + @stop)/2;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0, @start), color-stop(1, @stop));
}
// Box shadow
// -------------------------
.drop-shadow(@horizontal: 0, @vertical: 1px, @blur: 2px, @alpha: 0.1) {
-webkit-box-shadow:@horizontal @vertical @blur rgba(0, 0, 0, @alpha);
box-shadow:@horizontal @vertical @blur rgba(0, 0, 0, @alpha);
}
// Box shadow inset
// -------------------------
.inner-shadow(@horizontal: 0, @vertical: 1px, @blur: 2px, @alpha: 0.4) {
-webkit-box-shadow:inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);
box-shadow:inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);
}
// Box inner border
// -------------------------
.inner-border(@width: 1px, @color: #000) {
-webkit-box-shadow:inset 0 0 0 @width @color;
box-shadow:inset 0 0 0 @width @color;
}
// Box shadow default
// -------------------------
.box-shadow(@arguments) {
-webkit-box-shadow:@arguments;
box-shadow:@arguments;
}
// Animation
// -------------------------
.animation(@animation) {
-webkit-animation:@animation;
animation:@animation;
}
.transition(@transition) {
-webkit-transition:@transition;
transition:@transition;
}
.transition-delay(@transition-delay) {
-webkit-transition-delay:@transition-delay;
transition-delay:@transition-delay;
}
.transition-duration(@transition-duration) {
-webkit-transition-duration:@transition-duration;
transition-duration:@transition-duration;
}
// Transform
// -------------------------
.transform(@arguments) {
-webkit-transform:@arguments;
transform:@arguments;
}
// Transform rotation
// -------------------------
.rotation(@deg:5deg) {
-webkit-transform:rotate(@deg);
transform:rotate(@deg);
}
// Transform scale
// -------------------------
.scale(@ratio:1.5) {
-webkit-transform:scale(@ratio);
transform:scale(@ratio);
}
// Translate
// -------------------------
.translate(@x:0, @y:0) {
-webkit-transform:translate(@x, @y);
transform:translate(@x, @y);
}
// Translate3d
// -------------------------
.translate3d(@x, @y, @z) {
-webkit-transform:translate3d(@x, @y, @z);
transform:translate3d(@x, @y, @z);
}
// Background clipping
// -------------------------
.background-clip(@clip) {
-webkit-background-clip:@clip;
background-clip:@clip;
}
// CSS columns
// -------------------------
.columns(@colwidth: 250px, @colcount: 0, @colgap: 50px, @columnRuleColor: #EEEEEE, @columnRuleStyle: solid, @columnRuleWidth: 1px) {
-webkit-column-width:@colwidth;
-webkit-column-count:@colcount;
-webkit-column-gap:@colgap;
-webkit-column-rule-color:@columnRuleColor;
-webkit-column-rule-style:@columnRuleStyle;
-webkit-column-rule-width:@columnRuleWidth;
column-width:@colwidth;
column-count:@colcount;
column-gap:@colgap;
column-rule-color:@columnRuleColor;
column-rule-style:@columnRuleStyle;
column-rule-width:@columnRuleWidth;
}
// Import font
// -------------------------
.font-face(@fontFamily, @fileName, @style, @weight) {
@font-face{
font-family:@fontFamily;
font-style:@style;
font-weight:@weight;
src:url('@{fileName}.eot');
src:local('@fontFamily'), url('@{fileName}.eot?#iefix') format('embedded-opentype'), url('@{fileName}.woff') format('woff'), url('@{fileName}.ttf') format('truetype'), url('@{fileName}.svg#@{fontFamily}') format('svg'), url("@{fileName}.otf") format('opentype');
}
}
// Clearfix
// -------------------------
.clearfix() {
zoom:1;
&:before{
content:'';
display:block;
}
&:after{
content:'';
display:table;
clear:both;
}
}
// CSS image replacement
// -------------------------
// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
.hide-text() {
font:0/0 a;
color:transparent;
text-shadow:none;
background-color:transparent;
border:0;
}
// Force line breaks
// -------------------------
.word-break() {
word-break:break-all;
word-wrap:break-word;
white-space: normal;
}
// No wrap
// -------------------------
.no-wrap() {
word-break: normal;
word-wrap: normal;
white-space: nowrap;
}
// Text overflow with(...)
// -------------------------
// Requires inline-block or block for proper styling
.text-overflow() {
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
max-width:100%;
}
.line-overflow(@line) {
overflow:hidden;
text-overflow:ellipsis;
display:-webkit-box;
-webkit-line-clamp:@line; /* number of lines to show */
-webkit-box-orient:vertical;
}
// Creates a wrapper for a series of columns
// -------------------------
.lay-row() {
// Negative margin the row out to align the content of columns
margin-left: (@grid-gutter-width / -2);
margin-right: (@grid-gutter-width / -2);
// Then clear the floated columns
.clearfix();
}
// Generate the columns
// -------------------------
.lay-column(@columns) {
@media (min-width: @grid-float-breakpoint) {
float: left;
// Calculate width based on number of columns available
width: percentage(@columns / @grid-columns);
}
// Prevent columns from collapsing when empty
min-height: 1px;
// Set inner padding as gutters instead of margin
padding-left: (@grid-gutter-width / 2);
padding-right: (@grid-gutter-width / 2);
}
// Generate the column offsets
// -------------------------
.lay-column-offset(@columns) {
@media (min-width: @grid-float-breakpoint) {
margin-left: percentage((@columns / @grid-columns));
}
}
// Alpha background
// -------------------------
.alpha-background(@rgb:#000,@alpha:.5){
@rgba-color:fade(@rgb,@alpha*100);
@argb-color:argb(@rgba-color);
background-color:@rgba-color;
zoom:1;
}
// Controls the selection model of an element.
// -------------------------
.user-select(@arguments:none){
-webkit-user-select: @arguments;
user-select: @arguments;
}
// Flexbox display
// -------------------------
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: @display;
}