A
A
Alexander2016-06-14 14:44:23
Sass
Alexander, 2016-06-14 14:44:23

How to make an image path mixin?

I'm trying to master SCSS
I want to make a mixin so that each time I don't write the path to the pictures, but automatically when assembling it, I would
try to do it

@mixin img_bg($src) {
  background-image: url(../img/[email protected]);
}
@include img_bg("cherv_bg.jpg");

the result is url(../img/[email protected])
instead of the value of the variable - the name is substituted

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2016-06-14
@alexmixaylov

@mixin img_bg($src) {
  background-image: url(../img/#{$src});
}
@include img_bg("cherv_bg.jpg");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question