We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
calc()
url()
$sidebar-width: 250px; .main { width: calc(100% - $sidebar-width); } //你会惊讶地发现,根本不work。没有报错,容器的大小却又不正确。如果你去审查你的dom元素,你会看到这个 — 被划掉了。因为,这是不合法的 //因为calc()是一个CSS函数,不是一个Sass函数。这就是说Sass会将整个表达式解释成一个字符串 $type-of-expression: type-of(calc(100% - $sidebar-width)); // string .main{ width:calc(100% - #{$sidebar-width}); } //$sidebar-width被认为是一个常规字符串,所以打出来就是它自己,当我们用插值这样做时,Sass编译这个样式文件时,它会用#{$sidebar-width}的值,即 .main { width: calc(100% - 250px); }
@for $i from 1 through $max { .el:nth-of-type(#{$i}) { ... } } //for循环和:nth-*()选择器一起使用。再一次说明,你需要使用插值变量,才能最终得到想得到的结果
@support
@page
@media
//如果你的变量在@media字符串后面,需要使用插值才可以 $value : screen; @media #{$value} { ... }
//如果@media后面紧跟(),你就不再需要插值变量里,因为sass会求出所有在这些括号里的值 $value: 1336px; @media (max-width: $value) { ... }
$media: screen; $feature: -webkit-min-device-pixel-ratio; $value: 1.5; @media #{$media} { .sidebar { @media (#{$feature}: #{$value}) { width: 500px; } } } //编译后 @media screen and (-webkit-min-device-pixel-ratio: 1.5) { .sidebar {width: 500px; } }
$value : cunstom; selector-#{$value} { property : value; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
calc()
,url()
等@support
,@page
,@media
The text was updated successfully, but these errors were encountered: