Background image CSS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Background image CSS

Why isn't my image starting from the top? Seeing vertically, my image is starting from the middle. Why's that happening and how to avoid it? https://code.sololearn.com/WA75rW12je4G/?ref=app

16th Nov 2021, 10:28 AM
Rishi
Rishi - avatar
6 Answers
+ 1
remove the background-position property
16th Nov 2021, 1:34 PM
Gordon
Gordon - avatar
+ 2
Because the height of the image is less than the page height, so the image is repeated to cover all the page
16th Nov 2021, 10:39 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 2
Gordon yeah it's working, tnx. Can you help me to centre it horizontally, but stay the same vertically?
17th Nov 2021, 5:30 AM
Rishi
Rishi - avatar
+ 2
Gordon thank you very much =)
17th Nov 2021, 5:51 AM
Rishi
Rishi - avatar
+ 1
Muhammad yeah I know that. My question is why my image is starting to repeat from middle? It should've started to repeat from the top right? In other words, the girl's face should've been visible before her hand
16th Nov 2021, 10:43 AM
Rishi
Rishi - avatar
+ 1
background-position: 50% 0%; first percentage is horizontal second percentage is vertical https://code.sololearn.com/WDXq9AHAezWa/?ref=app Another combination: center top https://code.sololearn.com/Wz7lwtxVf3Gn/?ref=app
17th Nov 2021, 5:34 AM
Gordon
Gordon - avatar