0

I am having a problem with covering the background in CSS.

Before:

.main-bg {
  background: no-repeat url("../../images/main_bg.jpeg");
  height: 100vh;
  color: white;
}

Image Before

After:

.main-bg {
  background: no-repeat url("../../images/main_bg.jpeg") cover;
  height: 100vh;
  color: white;
}

Image After

Anyone know how to fix this? Thanks!

jvn11
  • 5
  • 3

1 Answers1

0

You cannot have cover alone in the background property. You are obliged to define the position as well:

background: no-repeat url("../../images/main_bg.jpeg") center/cover;

Or add background-size: cover

Related: Error: CSS: background: / is an incorrect operator

Temani Afif
  • 245,468
  • 26
  • 309
  • 415