Rob Hudson
Rob Hudson

Reputation: 81

background image not showing using css

I am trying to write into the CSS to show an image as the background and make it cover the page.

I am using the following code saved as css/varPractice.css

body {
background-image: url("img/beautifulPic.jpg");
background-size: cover;
background-image: no-repeat;
}

and have the following line in my html doc.

<link rel="stylesheet" href="css/varPractice.css">

however no pictures shows at all. This is the only style sheet link in that html file.

Any advice?

Upvotes: 0

Views: 659

Answers (2)

Joseph Marikle
Joseph Marikle

Reputation: 78520

You are redeclaring background-image. It looks like you meant to use background-repeat.

Your rule should read as follows:

body {
  background-image: url("img/beautifulPic.jpg");
  background-size: cover;
  background-repeat: no-repeat;
}

Upvotes: 2

K. Tromp
K. Tromp

Reputation: 360

Try to remove the background-image: repeat; It should be background-repeat: repeat; You were overwriting the background image.

Upvotes: 2

Related Questions