Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不知道如何创建一个自选择器。我最好的猜测是:
.mixin(@var) { &(~':nth-of-type(@{var}n)') { // do stuff } }
但是当用作
.el { .mixin(3); }
生产
.el :nth-of-type(3n) { //do stuff }
并且未能产生预期的结果。
感谢您在这方面的任何帮助。谢谢。
这取决于您使用的是哪个版本的 LESS,但对于 1.3.3,这应该可以工作
.mixin(@var) { @nthItem: ~":nth-of-type(@{var}n)"; &@{nthItem} { // do stuff } }