Paul Barlow
Paul Barlow

Reputation: 33

I am unable to see my image background with in the header section of my webpage when using CSS

I am creating a simple webpage and I am trying to place an image as a background within my header section. I am having some trouble with in the CSS section of my code. I believe I have used the right code, when assigning the background image, and my pathway and image name is all correct. Is there something I have done wrong?

CSS SECTION:

header{
background-color: rgba(0, 0, 0, .5);
background-image: url("images/home.png");
background-size: 100%;
background-position: center;
background-repeat: no-repeat;
height: 300px;
margin: 0;
padding: 20px;
position: relative;

Upvotes: 3

Views: 66

Answers (2)

s1834
s1834

Reputation: 443

Your code is correct but there might an error in the url, check it and it will surely work.

And I have a suggestion for you next time you code instead of % and px use Viewport Units like vw and vh because it will help you make your webpage/website responsive.

Upvotes: 1

Rahul Kumar
Rahul Kumar

Reputation: 17

Actually it's working fine in my PC, but i have some suggestion which you must try if you have done already try again, because your code is correct and then there must be another issue. You should check the path of image properly and spellings too and the extension of image is .png or something else otherwise everything is right.

And one more thing try some other css property on header section to check if it applying or not.

I hope it might work.

Upvotes: 1

Related Questions