How can i use a photo background in my code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can i use a photo background in my code ?

24th Dec 2020, 5:52 PM
Riselda Rada
Riselda Rada - avatar
6 Answers
+ 5
there are multiple ways to do this. One is simply using : body { background-img: url ("img.jpg") } One problem I find with this strategy sometimes, is the background is repeated. Another way to do this to make sure the image is not repeated, is this: HTML: <div id="image"></div> CSS: #image { content: ""; position: absolute ; left:0; top:0; width:100%; height: 100%; background:url("img.jpg"); background-size:cover; background-position:center; user-select:none; } Hope this helps!!
27th Feb 2021, 5:41 PM
don't be sad 😶
don't be sad 😶 - avatar
+ 4
Riselda Rada anytime 😄
27th Feb 2021, 5:44 PM
don't be sad 😶
don't be sad 😶 - avatar
+ 2
Thank you 🙏🏻🙏🏻
25th Dec 2020, 8:25 AM
Riselda Rada
Riselda Rada - avatar
+ 2
don't be sad 😶 thats awesome . i am trying . thank you very much♥️
27th Feb 2021, 5:43 PM
Riselda Rada
Riselda Rada - avatar
+ 1
Use style tag in head tag like this: <head> <style> Body{ background-image: url("image.jpg") } </style> <head>
24th Dec 2020, 6:13 PM
Nitin Kushwaha
Nitin Kushwaha - avatar