Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - Prevent background image from moving when zooming out

Tags:

html

css

Below is my code for my situation.

Currently the background image just gets smaller as I scroll out. I don't want it to repeat; I just want it to stay in place as I scroll out.

html {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: url("/img/background.png");
  background-repeat: no-repeat;
  background-attachment: fixed;
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-y: hidden;
}
like image 842
Darius Moseley Avatar asked Sep 16 '25 12:09

Darius Moseley


1 Answers

You may need background-size:cover in the body

like image 65
t.. Avatar answered Sep 18 '25 06:09

t..