升级到 LESS 1.4.0 后,我在以下代码的第一行出现编译错误:
(~"@{containerClass} .scrollElement.nth-child-@{index}") {
// the resulting css
left: @index * @seTotalWidth - @seTotalWidth;
}
编译错误:无法识别的输入
此代码在 LESS 1.4.0 中的外观如何?
我在http://lesscss.org/上注意到 ~" 已被弃用,但不是如何将它用于多个元素。
“完整”来源供参考
// Caller
.setPositionLeftForScrollElements ("#fgScroller", @maxFeaturedGuides + 2, @seTotalWidth);
// will be called as long the index is above 0
.setPositionLeftForScrollElements (@containerSelector, @index, @seTotalWidth) when (@index > 0) {
~"@{containerSelector} .scrollElement.nth-child-@{index}" {
// the resulting css
left: @index * @seTotalWidth - @seTotalWidth;
}
~"@{containerSelector} .scrollElement:nth-child(@{index})" {
// the resulting css
left: @index * @seTotalWidth - @seTotalWidth;
}
// next iteration
.setPositionLeftForScrollElements(@containerSelector, @index - 1, @seTotalWidth);
}
应用@seven-phases-max 建议的更改后的源代码
.setPositionLeftForScrollElements (~"#fgScroller", @maxFeaturedGuides + 2, @seTotalWidth);
// will be called as long the index is above 0
.setPositionLeftForScrollElements (@containerSelector, @index, @seTotalWidth) when (@index > 0) {
@{containerSelector} .scrollElement.nth-child-@{index} {
// the resulting css
left: @index * @seTotalWidth - @seTotalWidth;
}
@{containerSelector} .scrollElement:nth-child(@{index}) {
// the resulting css
left: @index * @seTotalWidth - @seTotalWidth;
}
// next iteration
.setPositionLeftForScrollElements(@containerSelector, @index - 1, @seTotalWidth);
}