Answer the question
In order to leave comments, you need to log in
Lines in less
Is it possible to use strings in functions to create selectors?
Let me explain with an example:
.btn-green{
.btn-color(@green, @white);
}
.btn-green:hover{
background: @green;
}
.btn-green:active,
.btn-green:focus{
.btn-active(@green);
}
.btn-color(@color, @font-color)
{
.gradient(lighten(@color, 10%), @color);
color: @font-color;
border: 1px solid @color;
text-shadow: 0 0 1px lighten(@color, 10%);
}
.btn-active(@color)
{
box-shadow: inset 0 0 4px fade(@color, 50%);
background: darken(@color, 3%);
}
.btn-color(@name, @color, @font-color){
@name:hover{
//
}
@name:active{
//
}
}
Answer the question
In order to leave comments, you need to log in
In less, these are Mixins.
Can you do it like this
.btn-pretty(@color) {
&:hover {
color: darken(@color, 10%);
}
&:active {
color: darken(@color, 20%);
}
}
.btn-green {
.btn-pretty(#f4f4f4);
}
.btn-green:hover{color:#dbdbdb;}
.btn-green:active{color:#c1c1c1;}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question