0

CSS link to html

Hi can someone help me with this issue. My Css file is in the same directory as my html file. But my image isn't loading. I'm using sublime text. My css code is div { background: url("IMG_3672.JPG") no-repeat; background-size: cover; } Below is my html file <head> <link rel="stylesheet" href="HelloWorld.css"> </head> <body> <div></div> </body>

10th Mar 2019, 2:26 PM
Tan Fu Yu
Tan Fu Yu - avatar
27 ответов
+ 9
Try using other css properties to see if its the image that is not loading or is it that css file is not linked properly with html. If other properties too don't work you have problem wih linking of css file. If it does check this: Is your image in the same directory? Are you using the right file extension?
10th Mar 2019, 6:33 PM
Mitali
Mitali - avatar
+ 7
Is image in same directory?
10th Mar 2019, 2:43 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 7
So, there is 3 file in same folder? .html, .css, .jpg
10th Mar 2019, 2:45 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 6
Try div width\height in px, in % don't work at me too. and take out " from url. simple (.jpg)
10th Mar 2019, 3:03 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 6
In my guides it written whithout ", but yes, it works and with ". When you take size of div with picture size in px, did it work?
10th Mar 2019, 3:24 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 5
Try write path to image in .html, not in css. As <img>.
10th Mar 2019, 4:11 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 5
How i find px instead % for myself at now? Your div empty, try to place in it some word. With % it will appear and picture appear in size of word. When i write in px in size of picture. Picture appear fully.
10th Mar 2019, 4:21 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 5
Mac... Mac.. For mac all usual css selectors works properly? Or, how for webkit, you should write -webkit-...?
10th Mar 2019, 4:23 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 5
div { background: url("IMG_3672.JPG") no-repeat; background-size: cover; Padding:10%; }
10th Mar 2019, 5:46 PM
Yash🏁🔘
Yash🏁🔘 - avatar
+ 4
When div has no element then the div space is not occupied when we put padding it create a invisible wall covering div so in that space it get display according to me
10th Mar 2019, 7:19 PM
Yash🏁🔘
Yash🏁🔘 - avatar
+ 3
You have not inserted div in html that y it not showing effects 😂😂 in css Chang div to body it will definitely work
10th Mar 2019, 5:10 PM
Yash🏁🔘
Yash🏁🔘 - avatar
+ 3
Okay in css just add padding I just tried it it's working
10th Mar 2019, 5:21 PM
Yash🏁🔘
Yash🏁🔘 - avatar
+ 2
Николай Шаповаленко yes save html and css in the same folder
10th Mar 2019, 2:44 PM
Tan Fu Yu
Tan Fu Yu - avatar
10th Mar 2019, 2:47 PM
Tan Fu Yu
Tan Fu Yu - avatar
+ 2
<link rel="stylesheet" type="text/css" href="name_of_file.css"> Try type
10th Mar 2019, 4:00 PM
Yash🏁🔘
Yash🏁🔘 - avatar
10th Mar 2019, 8:33 PM
Tan Fu Yu
Tan Fu Yu - avatar
+ 1
10th Mar 2019, 2:38 PM
Tan Fu Yu
Tan Fu Yu - avatar
+ 1
「HAPPY TO HELP」 tried width and height 100% too but it still doesn't work
10th Mar 2019, 2:52 PM
Tan Fu Yu
Tan Fu Yu - avatar
10th Mar 2019, 3:18 PM
Tan Fu Yu
Tan Fu Yu - avatar
+ 1
Николай Шаповаленко both doesn't work for me. Remove " but it doesn't work. Tried in PX and it doesn't work also. I'm using mac btw
10th Mar 2019, 4:00 PM
Tan Fu Yu
Tan Fu Yu - avatar