0

I've in laravel resource/sass/app.scss. In a such code:

.card {
    ..
    background: url(/img/plus-green.png) no-repeat;
    ..
}

Is it possible to make an url according to website location e.g url(<?=url('/imgs/img.png')?>), that if website is in my localhost xampp http://localhost/myproj/public/imgs/img.png or in a live https://example.com/imgs/img.png . I'm looking for make dynamical urls to css.

user2301515
  • 4,903
  • 6
  • 30
  • 46

1 Answers1

1

You should use relative paths instead of absolute paths.

Read more here on relative vs absolute paths.

You should change your code from:

.card {
    ..
    background: url(/img/plus-green.png) no-repeat;
    ..
}

to

.card {
    ..
    background: url(../img/plus-green.png) no-repeat;
    ..
}
Shef
  • 44,808
  • 15
  • 79
  • 90