I am trying to display a background image in my CSS and have used the relative path to the image. I have tried using different browsers but nothing seems to work. Below is my HTML.
<header>
<h2><a href="#">Rachel Doyle Studio</a></h2>
<nav>
<li><a href="#">Home</a></li>
<li><a href="#">Embroidery</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</nav>
</header>
<section class="thimble">
<div class="background-image" style="background-image: url(assets/img/art-arts-and-crafts-bright-colours-2564890.jpg)"></div>
<div class="thimble-content-area">
<h1>Rachel Doyles Studio</h1>
</div>
</section>
and below is the CSS styling for the class of background-image.
.thimble background-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: cover;
z-index: -1;
}
I have attached a picture of the structure of my files.
Why is it doing this even though I have the correct path to jpeg.
You can use this code
body {
margin: 0;
}
.thimble .background-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: cover;
background-image: url('https://www.w3schools.com/images/picture.jpg');
background-repeat: no-repeat;
z-index: -1;
}
<header>
<h2><a href="#">Rachel Doyle Studio</a></h2>
<nav>
<li><a href="#">Home</a></li>
<li><a href="#">Embroidery</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</nav>
</header>
<section class="thimble">
<div class="background-image"></div>
<div class="thimble-content-area">
<h1>Rachel Doyles Studio</h1>
</div>
</section>