使用sass混合指令

前言

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$breakpoints: ('sm':'only screen and (max-device-width: 1024px)','md': 'only screen and (min-device-width: 1025px) and (max-device-width: 1680px)', 'lg': 'only screen and (min-device-width: 1681px)');
@mixin respond-to($screensize){
$value: map-get($breakpoints,$screensize);
@if not $value{
@error 'no value found'
}
@media #{$value}{
@content;
}
}

@mixin respond-font-size($sizes){
@each $key,$value in $sizes{
@include respond-to($key){
font-size: #{$value}px;
}
}
}