Search code examples
cssbackground-image

How to set background-image to an image in your source folder?


I am trying to display an image I have in my source folder as the background-image of my Jumbotron below:

<div class="jumbotron" style="background-image: url(assets\images\bar.jpg); background-size: 100%;"></div>

The assets/images/bar.jpg path displays the image with a regular tag, but it isn't appearing when used as a url above.

This is where my image is stored: src/assets/images/bar.jpg

And here is where my HTML is: src/app/event-page/event-page.component.html

Can someone please tell me what changes I need to make so that this image is displayed in the background of my jumbotron? Thanks a lot!


Solution

  • As Abdul Basit said, you need to do ../../assets/images/bar.jpg enter image description here