0

here i want to create a less mixin. The parameter is brand and is should be changed into brand@2x.png. The code below did not work.

.bglogo (@brand) {
  @brandurl: @brand + '@2x.png';
  background-image: url(@brandurl);
}

.span{
  .bglogo('brand');
}

error message --

enter image description here

Mohammad Sadiqur Rahman
  • 5,379
  • 7
  • 31
  • 45
erikyu
  • 9
  • 2
  • Duplicate of [Is there a way to set a common image path for LESS files?](http://stackoverflow.com/questions/6294126/is-there-a-way-to-set-a-common-image-path-for-less-files) – seven-phases-max Feb 18 '17 at 08:46

1 Answers1

1

You need to use variable interpolation in order to concatenate the variable and the string.

In your case, you would use the value "@{brand}@2x.png":

.bglogo (@brand) {
  @brandurl: "@{brand}@2x.png";
  background-image: url(@brandurl);
}

.span {
  .bglogo('brand');
}

Result:

.span {
  background-image: url("brand@2x.png");
}
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304