我最近从 SASS 切换到了 Less(工作),并且想知道是否可以从 Less 获得这个输出(使用 mixin):
footer {
width: 768px;
@media only screen and (min-width: 992px) {
width:900px;
}
@media only screen and (min-width: 1200px) {
width:1200px;
}
}
我似乎只能像这样在单独的断点中获得输出(而不是在选择器下):
@media only screen and (min-width: 720px) and (max-width: 959px) {
footer {
width: 768px;
}
}
@media only screen and (min-width: 960px) and (max-width: 1199px) {
footer {
width: 3939px;
}
}
这是我一直在使用的 mixin:
.respond-to(@respondto; @rules) when (@respondto = "lg") {
@media only screen and (min-width: 1200px) {
@rules();
}
}
.respond-to(@respondto; @rules) when (isnumber(@respondto)) {
@media only screen and (min-width: @respondto) {
@rules();
}
}
然后像这样使用它:
div.class {
.respond-to(120px, {
float:left;
});
.respond-to("lg", {
float:none;
});
}
任何帮助,将不胜感激!