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.

1 Answer 1

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;
    ..
}
Sign up to request clarification or add additional context in comments.

3 Comments

The compilation makes "images/minus.png", how to do that it makes "myproj/public/imgs/minus.png"??
I need absolute paths in CSS. The laravel scss compiles wrong them.
@user2301515 I made a slight edit, check it now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.