How do I set the bg image so that it stays the same while scrolling up and down without repeating? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

How do I set the bg image so that it stays the same while scrolling up and down without repeating?

The background image is full-screen on th current page but when I scroll down, the image is in loop, although still full-screen, the background image just keeps on repeating while scrolling up and down. Already tried using background-repeat and background-attachment properties. But it won't work.

5th Jul 2022, 3:38 PM
Meow Meow
Meow Meow - avatar
10 Answers
+ 3
Meow Meow it is not possible to see why your code did not work before. You did not provide your code. SomeAwesome provided a code. But it is not that helpful with out your code. Since we can not compare the two codes. So please whenever you have a code related question please provide your code sample.
5th Jul 2022, 5:42 PM
Chris Coder
Chris Coder - avatar
+ 1
Could you share ur code?
5th Jul 2022, 3:56 PM
SomeAwesome
SomeAwesome - avatar
+ 1
Oh sorry I didnt read properly… Did it really not work? Can you give us you code, so I can look for mistakes
5th Jul 2022, 3:57 PM
Janne
Janne - avatar
5th Jul 2022, 4:13 PM
SomeAwesome
SomeAwesome - avatar
0
background-attachement: fixed ; That should work 👍
5th Jul 2022, 3:56 PM
Janne
Janne - avatar
0
Actually the code is pretty simple, I just added the background image. Like, background-image:url("random.jpg"); And it was a pure coincidence that the image fit perfectly on the viewable screen. The only problem is that, when I scroll down, the image just repeats itself. But I want the image to remain the same on every page without getting scrolled, like the background just never changes even when I scroll up to down and bottom to top again.
5th Jul 2022, 4:01 PM
Meow Meow
Meow Meow - avatar
0
SomeAwesome thank you for answering 😊♥️
5th Jul 2022, 4:18 PM
Meow Meow
Meow Meow - avatar
0
SomeAwesome but Idk why it didn't work when I tried it at first.
5th Jul 2022, 4:22 PM
Meow Meow
Meow Meow - avatar
0
Chris Coder alright 😊
6th Jul 2022, 11:31 AM
Meow Meow
Meow Meow - avatar
0
Use background cover property
7th Jul 2022, 2:57 PM
Muhammad Umer Mushtaq
Muhammad Umer Mushtaq - avatar