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

Background img

Hello. Does someone have a clue why background: url image in css does display on bracket's live preview but do not show in any other browser?? :-(

3rd Aug 2017, 10:01 PM
Maciej Mazurek
Maciej Mazurek - avatar
7 Answers
+ 1
It doesn't help:-( my css code is: header { background: url(/img/man-1.jpg) no-repeat center center; background-size:cover; width:100%; height:100vh; position absolute; } On live preview everything is fine but when i pushed my project on github and try to display in od githubpages, background dont no want to show... Then i tried to open index.htm on Chrome and Firefox and dont work as well...
4th Aug 2017, 5:45 AM
Maciej Mazurek
Maciej Mazurek - avatar
+ 3
Everything is fine with the CSS, except I am a little suspicious about that url(), you need to make sure that it points to the image.
4th Aug 2017, 12:52 PM
Stamen
Stamen - avatar
+ 1
Are you sure you saved it before opened in other browsers?
4th Aug 2017, 11:50 AM
Stamen
Stamen - avatar
+ 1
Yes I made commit and send it to github pages. I can see my files there and when i open css file directly on github whole code is there... The other styling for text and body etc is ok but only background image don't show up...
4th Aug 2017, 12:11 PM
Maciej Mazurek
Maciej Mazurek - avatar
+ 1
I final got this... Patch to background image has to be url(.. /img/man-1.jpg) :-) thank for a hint
4th Aug 2017, 4:27 PM
Maciej Mazurek
Maciej Mazurek - avatar
+ 1
Glad to help :)
4th Aug 2017, 7:05 PM
Stamen
Stamen - avatar
0
Sometimes browsers cache css and they won't reload a fresh one. If you are using chrome try refreshing a page by CTRL + F5, that shortcut will clear the cache and hopefully solve your problem.
3rd Aug 2017, 10:17 PM
Stamen
Stamen - avatar