Answer the question
In order to leave comments, you need to log in
Is it possible to use the value of the less variable as the name of another variable and mixin?
I do not paint the question in more detail, since there will be too many beeches. I'm trying to do what they talked about at codefest 2gis: www.slideshare.net/codefest/codefest-2014-2
At the same time, I only have this presentation, and that's it - no video, nothing else.
Stages with generation of base64, png-sprite and css are completed.
Now I would like to collect everything in a single mixin.
For starters, the version with the base64 icon and no fallback for ie8.
This mixin generates the required CSS, but for the "icons_zoom" icon:
.bg-icon(@filename) {
.data-icons_zoom; // берем base64 из сгенерированного css
background-repeat: no-repeat;
.sprite-width(@icons_zoom); // берем размеры иконки из css для спрайта (больше неоткуда)
.sprite-height(@icons_zoom);
}
.bg-icon(@filename) {
[email protected];
background-repeat: no-repeat;
.sprite-width(@@filename);
.sprite-height(@@filename);
}
Answer the question
In order to leave comments, you need to log in
@@filename - you can.
Mixins can be done via guards:
@sprite1: 100px;
@sprite2: 200px;
.data-sprite(@filename) when (@filename = sprite1) {
background: red;
}
.data-sprite(@filename) when (@filename = sprite2) {
background: green;
}
.sprite-width(@width) {
width: @width;
}
.sprite-height(@width) {
height: @width;
}
.bg-icon(@filename) {
.data-sprite(@filename);
background-repeat: no-repeat;
.sprite-width(@@filename);
.sprite-height(@@filename);
}
html {
.bg-icon(sprite1);
}
body {
.bg-icon(sprite2);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question