Kumo Mit
Kumo Mit

Reputation: 11

Can not display background-image in laravel

please help me! In resources/views/welcome.bale.php:

<link rel="stylesheet" href="{{asset('css/style.css')}}">
<div class="factarea overlay">
    <h2>Facts that Make us Unique</h2>
</div>

In public folder: css/style.css

.factarea {background-image: url(../img/website.jpg);}

public/img/website.jpg location

Upvotes: 0

Views: 82

Answers (2)

Priyank Panchal
Priyank Panchal

Reputation: 119

I hope the below line will help you to resolve this issue.

You can try this.

  • background-image: url("/img/website.jpg");

You can try with another way like in-line css and check what we getting the image or not. so we can easily find the correct path.

Thanks

Upvotes: 1

Kamlesh Paul
Kamlesh Paul

Reputation: 12391

use root path

.factarea {background-image: url(/img/website.jpg);}

like this then

websiteurl/img/website.jpg will work here

websiteurl/public/img/website.jpg will not work only pretty url will work

so in order to work in public url as well you have to add inline css

which is

<link rel="stylesheet" href="{{asset('css/style.css')}}">
<div class="factarea overlay" style="background-image: url({{ asset('img/website.jpg') }})">
    <h2>Facts that Make us Unique</h2>
</div>

Upvotes: 0

Related Questions