shivendra yadav
shivendra yadav

Reputation: 181

I am not able to set the background image using CSS

I am not able to understand why in the background the image is not getting displayed.

body{
	background-image: url('../Images/Chicken.jpeg');
	background: cyan;
}

The path of the image is right. whats the problem then? but the background color is getting being displayed.

Upvotes: 0

Views: 56

Answers (2)

akhtarvahid
akhtarvahid

Reputation: 9769

.main {
  background-image: url('https://image.shutterstock.com/image-photo/beautiful-water-drop-on-dandelion-260nw-789676552.jpg');
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-position: center; 
  height: 100vh;
}
<div class="main">
</div>

Upvotes: 0

demkovych
demkovych

Reputation: 8817

Because you override an image with the color. If you want to use them both:

body{
    background-image: url('../Images/Chicken.jpeg');
    background-color: cyan;
}

or you can combine them in to one line:

body{
    background: cyan url('../Images/Chicken.jpeg');
}

Upvotes: 7

Related Questions