I am uploading an image using background-image in css, and despite making sure the file path is correct and substituting another image for the original to see if the original image was the problem, I can not get the image to display. I know the file path is correct because I use VScode and it auto fills when I start typing. I also checked to make sure that my styles.css file was correctly entered by adding other css commands into the stylesheet, which worked.
Here is my code:
.header-image {
background-image: url("images/image.png");
background-size: cover;
}
<section class="header-image container-fluid">
</section>
2
Answers
You need to provide height to the image, and width accordingly.
you are applying a background image via css to a section element. The section needs an explicit height for the background image to be visible.
You can add content to the section element and verify it, the image will be visible for the content in the section.
If you do not want to add content to your section element try with the below styles by adding an explicit height in vanilla css.