Home > other >  Adding a background image to a site
Adding a background image to a site

Time:10-30

Just a heads up that I am not good at using html and css or anything webdev based. However, because I wanted a portfolio website to host my projects I followed a tutorial online and basically copy/pasted and adjusted it to suit me. The website itself has 4 sections: home, about me, projects and contact me.

I want to add an image as a background only for the home section but when I tried to add the background attribute to the body or to the section itself when refreshing I see it for a second then it disappears and a solid color takes place. So maybe it needs a change in the css file ? no clue.

Any advice or guidance ? I can't quite provide code here since I don't even know which one to provide but relevant things:

  1. In the index.html file the home section starts at line 25.
  2. the image I want is in the img subfolder and called banner.png

github repo: https://github.com/Armonia1999/Portfolio

website itself: https://armonia1999.github.io/Portfolio/

CodePudding user response:

Can you provide the section you're setting the background image to and also check your css, you might be overriding the image with a background color.

CodePudding user response:

You need to put the path into the background style attribute for the #home element

#home {
  background: url("img/banner.png");
}
  • Related