.size(@w, @h) { width: @w; height: @h; }
.min-width(@min-w) { min-width: @min-w; _width: @min-w; }
.min-height(@min-h) { min-height: @min-h; _height: @min-h; }
.dib() { display: inline-block; *display: inline; *zoom: 1; }
.fixed() { position: fixed; _position: absolute; *zoom: 1; }
.border-box() {
*, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
}
.center(text-x) { text-align: center; }
.center(text-y) { display: table-cell; vertical-align: middle; }
.center(auto-x) { display: block; margin-left: auto; margin-right: auto; }
.center(unknown) { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; }
.center(unknown-x) { position: absolute; left: 0; right: 0; margin-left: auto; margin-right: auto; }
.center(unknown-y) { position: absolute; top: 0; bottom: 0; margin-top: auto; margin-bottom: auto; }
.center(known, @w, @h) {
.size(@w, @h);
position: absolute; top: 50%; left: 50%; margin-top: -(@w / 2); margin-left: -(@h / 2);
}
.center(known-x, @w) {
width: @w;
position: absolute; left: 50%; margin-left: -(@h / 2);
}
.center(known-y, @h) {
height: @h;
position: absolute; top: 50%; margin-top: -(@w / 2);
}
.center(translate) { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.center(flex) { display: flex; align-items: center; justify-content: center; }
.list(float, @w: 25%) { float: left; width: @w; }
.list(inline, @w: 25%) { .dib(); width: @w; }
.list(flex) { flex: 1; }
.over-screen(fixed) { .fixed(); top: 0; left: 0; right: 0; bottom: 0; }
.over-screen(absolute) { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.fixed-ratio(@padding-top: 100%) {
position: relative; width: 100%; height: 0; padding-top: @padding-top;
img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
}
.extend-click() {
position: relative;
&:before { content: ''; position: absolute; top: -10px; left: -10px; right: -10px; bottom: -10px; }
}
.layout-page(@width: 1200px) { width: @width; margin-left: auto; margin-right: auto; }
.sidebar(left, @width) { position: absolute; top: 0; left: 0; width: @width; }
.sidebar(right, @width) { position: absolute; top: 0; right: 0; width: @width; }
.fz(@fz) { font-size: @fz; }
.fz(@fz, @lh) { font-size: @fz; line-height: @lh; }
.fz(@fz, @h, @lh: @h) { font-size: @fz; height: @h; line-height: @lh; }
.lh(@h, @lh: @h) { height: @h; line-height: @lh; }
.color(@color) { color: @color;}
.color(@color, @hovercolor) {
color: @color;
&:hover { color: @hovercolor; }
}
.color(@color, @acolor, @hovercolor) {
color: @color;
a {
color: @acolor;
&:hover { color: @hovercolor; }
}
}
.normal-font() { font-weight: normal; font-style: normal; }
.assist-font(@color: #b0b0b0, @fz: 14px) { color: @color; font-size: @fz; }
.ellipsis() {
white-space: normal; word-wrap:
break
-word; word-
break
:
break
-all;
-o-text-overflow: ellipsis; -ms-text-overflow: ellipsis; text-overflow:ellipsis; overflow:hidden;
}
.ellipsis-mult(@n: 3) {
display: -webkit-box; -webkit-box-orient: vertical;-webkit-line-clamp: @n; word-
break
:
break
-all;
-o-text-overflow: ellipsis; -ms-text-overflow: ellipsis; text-overflow:ellipsis; overflow: hidden;
}
.retext(x) { direction: rtl; unicode-bidi: bidi-override; }
.retext(y) { writing-mode: tb-rl; writing-mode: vertical-rl; }
.transparent-text() { font: 0/0 serif; text-shadow: none; color: transparent; }
.hidden-text() { text-indent : -9999px; overflow: hidden; text-align: left; }
.glow-text(@r: 10px, @color: gold) { text-shadow: 0 0 @r @color; }
.max-img() { display: block; max-width: 100%; height: auto; }
.bg-image(@url) {
background-image: url(
"@url + '@2x.png'"
);
@media (-webkit-min-device-pixel-ratio: 3), (min-device-pixel-ratio: 3) {
background-image: url(
"@url + '@3x.png'"
);
}
}
.fullscreen-bg(@url) {
width: 100vw;
height: 100vh;
background: url(@url) no-repeat 50% 50%;
background-size: cover;
}
.grayscale() {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
}
.hover-link() {
text-decoration: none;
&:hover { text-decoration: underline; }
}
.unstyled-link() {
color: inherit;
cursor: inherit;
text-decoration: inherit;
&:active, &:focus { outline: none; }
}
.box-shadow() {
box-shadow: 0px 14px 26px 0px rgba(0, 0, 0, 0.1);
}
.box-hover() {
transition: all .2s linear;
&:hover {
box-shadow: 0 15px 30px rgba(0, 0, 0, .1);
transform: translate3d(0, -2px, 0);
}
}
.box-hover2() {
transition: transform .5s ease;
&:hover {
transform: translateX(10px);
}
}
.transform-fix() { -webkit-backface-visibility: hidden; -webkit-transform-style: preserve-3d; }
.ani(@name, @time: 1s, @ease: ease-in-out, @fillmode: forwards) {
animation-name: @name;
animation-duration: @time;
animation-timing-
function
: @ease;
animation-fill-mode: @fillmode;
}
.fl() { float: left; *display: inline; _display:inline; }
.fr() { float: right; *display: inline; _display:inline; }
.clearfix() {
*zoom: 1;
&:after { display: block; clear: both; content: ''; visibility: hidden; height: 0; }
}
.clearfix(table) {
*zoom: 1;
&:before, &:after { content:
" "
; display: table; clear: both; }
}
.user-select() { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
.hide-cursor() { cursor: none !important; }
.disabled() { cursor: not-allowed; }
.pointer-events() { pointer-events: none; }
.blur(@blur: 10px) {
filter: blur(@blur);
-webkit-filter: blur(@blur);
-moz-filter: blur(@blur);
-o-filter: blur(@blur);
-ms-filter: blur(@blur);
filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius='@{blur}');
*zoom: 1;
}
.opacity(@opacity: 20) { opacity: @opacity / 100; filter: alpha(opacity=@opacity); }
.
print
-link() {
@media
print
{
a[href]:after { content:
" ("
attr(href)
") "
; }
}
}
.zebra-lists(odd, @color) {
&.odd {
>li:nth-child(odd) { background-color: @color; }
}
}
.zebra-lists(even, @color) {
&.even {
>li:nth-child(even) { background: green; }
}
}
.first-letter(@font-size: 6em) {
&::first-letter{
float: left;
line-height: 1;
font-size: @font-size;
}
}
.first-line() {
&::first-line{
color: red
}
}
.beauty-select() {
&::selection{
color: #fff;
background-color: #6bc30d;
text-shadow: none;
}
}
.beauty-placeholder(@fz, @color: #999, @align: left) {
&:-moz-placeholder { font-size: @fz; color: @color; text-align: @align; }
&:-ms-input-placeholder { font-size: @fz; color: @color; text-align: @align; }
&::-webkit-input-placeholder { font-size: @fz; color: @color; text-align: @align; }
}
.beauty-placeholder(custom, @property, @value) {
&:-moz-placeholder { @{property}: @value; }
&:-ms-input-placeholder { @{property}: @value; }
&::-webkit-input-placeholder { @{property}: @value; }
}
.triangle(@width: 4px,@color: #000) {
display: inline-block;
width: 0;
height: 0;
vertical-align: middle;
border-top: @width solid @color;
border-left: @width solid transparent;
border-right: @width solid transparent;
}
.arrow(top, @w: 10px, @color, @x: 50%) {
position: relative;
&:before { position: absolute; bottom: 100%; left: @x; content:
" "
; height: 0; width: 0; pointer-events: none; border-style: solid; border-color: transparent; border-bottom-color: @color; border-width: unit(@w, px); @margin: -@w; margin-left: unit(@margin, px); }
}
.arrow(right, @w: 10px, @color, @y: 50%) {
position: relative;
&:before { position: absolute; left: 100%; top: @y; content:
" "
; height: 0; width: 0; pointer-events: none; border-style: solid; border-color: transparent; border-left-color: @color; border-width: unit(@w, px); @margin: -@w; margin-top: unit(@margin, px); }
}
.arrow(bottom, @w: 10px, @color, @x: 50%) {
position: relative;
&:before { position: absolute; top: 100%; left: @x; content:
" "
; height: 0; width: 0; pointer-events: none; border-style: solid; border-color: transparent; border-top-color: @color; border-width: unit(@w, px); @margin: -@w; margin-left: unit(@margin, px); }
}
.arrow(left, @w: 10px, @color, @y: 50%) {
position: relative;
&:before { position: absolute; right: 100%; top: @y; content:
" "
; height: 0; width: 0; pointer-events: none; border-style: solid; border-color: transparent; border-right-color: @color; border-width: unit(@w, px); @margin: -@w; margin-top: unit(@margin, px); }
}
.arrow-with-border(top, @w: 10px, @color, @border-w: 1px, @border-color, @x: 50%) {
position: relative;
&:before, &:after { bottom: 100%; left: @x; content:
" "
; height: 0; width: 0; position: absolute; pointer-events: none; border-style: solid; border-color: transparent; }
&:after { border-bottom-color: @color; border-width: unit(@w, px); @margin: -@w; margin-left: unit(@margin, px); }
&:before { border-bottom-color: @border-color; @arrbo: @w+@border-w; border-width: unit(@arrbo, px); @margin-bo: -@arrbo; margin-left: unit(@margin-bo, px); }
}
.arrow-with-border(bottom, @w: 10px, @color, @border-w: 1px, @border-color, @x: 50%) {
position: relative;
&:before, &:after { top: 100%; left: @x; content:
" "
; height: 0; width: 0; position: absolute; pointer-events: none; border-style: solid; border-color: transparent; }
&:after { border-top-color: @color; border-width: unit(@w, px); @margin: -@w; margin-left: unit(@margin, px); }
&:before { border-top-color: @border-color; @arrbo: @w+@border-w; border-width: unit(@arrbo, px); @margin-bo: -@arrbo; margin-left: unit(@margin-bo, px); }
}
.arrow-with-border(left, @w: 10px, @color, @border-w: 1px, @border-color, @y: 50%) {
position: relative;
&:before, &:after { top: @y; right: 100%; content:
" "
; height: 0; width: 0; position: absolute; pointer-events: none; border-style: solid; border-color: transparent; }
&:after { border-right-color: @color; border-width: unit(@w, px); @margin: -@w; margin-top: unit(@margin, px); }
&:before { border-right-color: @border-color; @arrbo: @w+@border-w; border-width: unit(@arrbo, px); @margin-bo: -@arrbo; margin-top: unit(@margin-bo, px); }
}
.arrow-with-border(right, @w: 10px, @color, @border-w: 1px, @border-color, @y: 50%) {
position: relative;
&:before, &:after { top: @y; left: 100%; content:
" "
; height: 0; width: 0; position: absolute; pointer-events: none; border-style: solid; border-color: transparent; }
&:after { border-left-color: @color; border-width: unit(@w, px); @margin: -@w; margin-top: unit(@margin, px); }
&:before { border-left-color: @border-color; @arrbo: @w+@border-w; border-width: unit(@arrbo, px); @margin-bo: -@arrbo; margin-top: unit(@margin-bo, px); }
}
.fix-header(@h: 70px) {
.fixed();
top: 0;
left: 0;
width: 100%;
height: @h;
z-index: 1000;
}
.fix-header(@h: 70px) {
.fixed();
left: 0;
bottom: 0;
width: 100%;
height: @h;
z-index: 1000;
}
.input-text() {
display: block;
width: 100%;
padding: 4px 8px;
font-size: 14px;
line-height: 1.42858;
color: #333;
border: 1px solid #ddd;
background-color: #fff;
border-radius: 3px;
}
.separator() {
margin: 0 10px;
color: #999;
font-size: 14px;
}
.separator2() {
&:before {
padding: 0 5px;
color: #ccc;
content:
"/\00a0"
;
}
}
.hr() {
height: 1px;
margin: 10px 0;
border: 0;
clear: both;
background-color: #e2e2e2;
}
.fieldset() {
border-color: #d2d2d2;
border-width: 1px 0 0;
border-style: solid;
legend {
padding: 0 20px;
text-align: center;
font-size: 20px;
font-weight: 300;
}
}
.blockquote() {
margin-bottom: 10px;
padding: 15px;
line-height: 22px;
border-left: 5px solid #009688;
border-radius: 0 2px 2px 0;
background-color: #f2f2f2;
}
.badge(...) {
position: relative;
display: inline-block;
font-size: 12px;
color: #fff;
background-color: #FF5722;
}
.badge(ellipse) {
min-width: 8px;
height: 18px;
padding: 2px 6px;
text-align: center;
line-height: 18px;
border-radius: 9px;
}
.badge(dot) {
width: 8px;
height: 8px;
border-radius: 50%;
}
.close() {
position: relative;
-webkit-appearance: none;
padding: 0;
cursor: pointer;
background: 0 0;
border: 0;
font-size: 20px;
font-weight: 700;
line-height: 1;
color: #000;
text-shadow: 0 1px 0 #fff;
filter: alpha(opacity=20);
opacity: .2;
&:hover {
color: #000;
text-decoration: none;
cursor: pointer;
filter: alpha(opacity=50);
opacity: .5;
}
&:before {
content: '';
position: absolute;
top: -10px;
left: -10px;
right: -10px;
bottom: -10px;
}
}
.onepx(...) {
position: relative;
&:after {
content: '';
display: block;
position: absolute;
left: 0;
width: 100%;
border-top: 1px solid rgba(7, 17, 27, 0.1);
transform: scaleY(0.5);
}
}
.onepx(top) { &:after { top: 0; } }
.onepx(bottom) { &:after { bottom: 0; } }
.onepx-easy(top, @color: #ccc) { box-shadow: inset 0px -1px 1px -1px @color; }
.onepx-easy(bottom, @color: #ccc) { box-shadow: inset 0px 1px 1px -1px @color; }