Is there anything wrong in this css styling | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there anything wrong in this css styling

I wrote the following code to set an image as my background-image for div with class name main Code : .main{ padding-top:110px; padding-bottom:60px; background-image:url("../images/main.jpg"); background-color:yellow; background-size:cover; } Can anyone find anything wrong in this code because the image is not loading when I'm running the webpage but all other styling has been applied.

6th Apr 2020, 6:51 PM
Naveen K R
5 Answers
+ 2
Maybe the image url is incorrect.
6th Apr 2020, 7:08 PM
Pranav Kalro
Pranav Kalro - avatar
7th Apr 2020, 7:09 AM
Pranav Kalro
Pranav Kalro - avatar
0
Pranav Kalro it's correct I checked it
7th Apr 2020, 3:22 AM
Naveen K R
0
I copied that image to my css folder and it worked. Before that the following was my file path like Website css index.css images main.jpg index.html Isn't "../images/main.jpg" the correct way to link the main.jpg to index.css ?
7th Apr 2020, 3:43 AM
Naveen K R
0
I think you should export your main.jpg to the folder your index.css and html file is That way u can retrace URL problems easier
8th Apr 2020, 11:52 PM
Onfranciis
Onfranciis - avatar