Emanuel Rista
Emanuel Rista

Reputation: 55

SASS// Background Image path issue

I'm trying to set a background image for a class.

This is my file structure using laravel-mix:

enter image description here

What's wrong with my code in app.scss file?

.header-bg {
   background-image: url('img/illustration-main.jpg');
   background-size: cover;
}

Tried this but also not working:

.header-bg {
   background-image: url(require('img/illustration-main.jpg'));
   background-size: cover;
}

Here in case the content of the img folder:

enter image description here

Upvotes: 0

Views: 425

Answers (1)

plumsauced1
plumsauced1

Reputation: 118

If your css file is being built to dist/app.css your image path should be relative to this. Since your img folder is sibling to dist, try url('../img/illustration-main.jpg')

Upvotes: 1

Related Questions