css - sass background mixins using url -
this question has answer here:
- have variable in images path in sass? 3 answers
guys create background mixin instead writing repeated url
@mixin bgimage($name){ $url:"../images/$name.png"; background: url($url);} and,it never accept valuee $name variable
i called
@include bgimage(name.png); and in css output came wrong this
background: url("../images/$name.png"); is there way write url in mixin ? ot how in short way
try variable interpolation of #{$name}
@mixin bgimage($name) { $url:"../images/#{$name}.png"; background: url($url); } and pass filename, without extension, mixin parameter:
@include bgimage(your-png-file-without-extension); since appended in $url variable of mixin
Comments
Post a Comment