amis/scss/_functions.scss

43 lines
1.1 KiB
SCSS
Raw Normal View History

2019-04-30 11:11:25 +08:00
//下一个断点
@function breakpoint-next(
$name,
$breakpoints: breakpoints,
$breakpoint-names: map-keys($breakpoints)
) {
2019-04-30 11:11:25 +08:00
$n: index($breakpoint-names, $name);
@return if(
$n < length($breakpoint-names),
nth($breakpoint-names, $n + 1),
null
);
2019-04-30 11:11:25 +08:00
}
//断点最小值
@function breakpoint-min($name, $breakpoints: $breakpoints) {
$min: map-get($breakpoints, $name); // @return if($min != 0, $min, null);
@return $min;
}
//断点最大值
@function breakpoint-max($name, $breakpoints: $breakpoints) {
$next: breakpoint-next($name, $breakpoints);
@return if($next, breakpoint-min($next, $breakpoints) - 1px, null);
}
//生成类名“-sm、-md、-lg、-cl” -xs?
@function breakpoint-infix($name, $breakpoints: $breakpoints) {
@return if(breakpoint-min($name, $breakpoints) ==null, "", "-#{$name}");
2019-04-30 11:11:25 +08:00
}
@function px2rem($pixels, $context: $remFactor) {
@if (unitless($pixels)) {
$pixels: $pixels * 1px;
}
2019-04-30 11:11:25 +08:00
@if (unitless($context)) {
$context: $context * 1px;
}
2019-04-30 11:11:25 +08:00
@return $pixels / $context * 1rem;
}