将 Less 中使用 Guarded Namespace 的 Mixin 转换为 Sass
Converting Mixin using Guarded Namespace in Less to Sass
如何将以下用 LESS 编写的 mixin 转换为 SASS?
.box_gradient (@from, @to) when (iscolor(@from)) and (iscolor(@to)) {
background-image: -webkit-gradient(linear, left top, left bottom, from(@from), to(@to)); /* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, @from, @to); /* Chrome 10+, Saf5.1+, iOS 5+ */
background-image: -moz-linear-gradient(top, @from, @to); /* FF3.6 */
background-image: -ms-linear-gradient(top, @from, @to); /* IE10 */
background-image: -o-linear-gradient(top, @from, @to); /* Opera 11.10+ */
background-image: linear-gradient(to bottom, @from, @to);
}
这是在 SASS 中使用条件句完成的:
.box_gradient (@from, @to) {
@if (iscolor(@from) and iscolor(@to)) {
background-image: -webkit-gradient(linear, left top, left bottom, from(@from), to(@to)); /* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, @from, @to); /* Chrome 10+, Saf5.1+, iOS 5+ */
background-image: -moz-linear-gradient(top, @from, @to); /* FF3.6 */
background-image: -ms-linear-gradient(top, @from, @to); /* IE10 */
background-image: -o-linear-gradient(top, @from, @to); /* Opera 11.10+ */
background-image: linear-gradient(to bottom, @from, @to);
}
}
如何将以下用 LESS 编写的 mixin 转换为 SASS?
.box_gradient (@from, @to) when (iscolor(@from)) and (iscolor(@to)) {
background-image: -webkit-gradient(linear, left top, left bottom, from(@from), to(@to)); /* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, @from, @to); /* Chrome 10+, Saf5.1+, iOS 5+ */
background-image: -moz-linear-gradient(top, @from, @to); /* FF3.6 */
background-image: -ms-linear-gradient(top, @from, @to); /* IE10 */
background-image: -o-linear-gradient(top, @from, @to); /* Opera 11.10+ */
background-image: linear-gradient(to bottom, @from, @to);
}
这是在 SASS 中使用条件句完成的:
.box_gradient (@from, @to) {
@if (iscolor(@from) and iscolor(@to)) {
background-image: -webkit-gradient(linear, left top, left bottom, from(@from), to(@to)); /* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, @from, @to); /* Chrome 10+, Saf5.1+, iOS 5+ */
background-image: -moz-linear-gradient(top, @from, @to); /* FF3.6 */
background-image: -ms-linear-gradient(top, @from, @to); /* IE10 */
background-image: -o-linear-gradient(top, @from, @to); /* Opera 11.10+ */
background-image: linear-gradient(to bottom, @from, @to);
}
}