1

I have recently been creating a link in-bio page and I am trying to make the background image cover the whole screen but it is only covering parts of the screen where I have objects like a header or list. Below I have the CSS code that I used to insert the background image.

body {
background: url(./942775.png) no-repeat center center fixed;
background-size: cover;

}

misterManSam
  • 24,303
  • 11
  • 69
  • 89
Josh10187
  • 13
  • 3

1 Answers1

2

It's likely that your body element is not the full size of your viewport. Try stretching html and body to the full window:

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: url(https://www.nasa.gov/images/content/296150main_2-226.jpg) no-repeat center center fixed;
  background-size: cover;
}
main {
  color: white;
}
<main>Hello world</main>
Frish
  • 1,371
  • 10
  • 20