27cm
@27cm
TODO: Написать статус

Как написать миксин на LESS?

Как с помощью less написать .icon-before(), чтобы:
.icon-before("post", "file", "book", "check", "image", "globe", /* ... */ "data" );

превращался в:
.icon-post:before { content: '\e800'; }
.icon-file:before { content: '\e801'; }
.icon-book:before { content: '\e802'; }
.icon-check:before { content: '\e803'; }
.icon-image:before { content: '\e804'; }
.icon-globe:before { content: '\e805'; }
// ...
.icon-data:before { content: '\e80f'; }
  • Вопрос задан
  • 2788 просмотров
Решения вопроса 1
@neolink
.icon-before(@list...) {
    .do(@index, @list) when (@index <= length(@list)) {
            @name: extract(@list, @index);           
            .icon-@{name}:before {
                content: replace(%("\%a", rgb(0, 232, @index)), "#00", '') 
            }               
           .do(@index + 1, @list);
    }
    .do(1, @list);
}
.icon-before(post, file, book, check, image, globe, data, a1, a2, a3, a4);

jsfiddle.net/jwdrb6m6
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
DeLaVega
@DeLaVega
Верстаю, фронтэндю =)
На сколько я знаю - в лессе нет циклов, они есть в сассе.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы