简体   繁体   English

我的背景图片没有出现在 Github

[英]My Background Image Doesn't Show Up On Github

I have a sample landing page which I uploaded to gitHub.我有一个示例登录页面,我上传到 gitHub。 When I preview it on my computer with local files, everything works fine but I cannot see background image when I upload it to gitHub.当我使用本地文件在我的计算机上预览它时,一切正常,但是当我将它上传到 gitHub 时,我看不到背景图像。

I've tried below codes to make it work but couldn't.我试过下面的代码让它工作,但不能。 You can check gitHub respiratory from here if you wish. 如果您愿意,可以从这里检查 gitHub 呼吸系统。 And page from here. 并从这里开始。

background-image: url(images\main.jpg);
background-image: url(/images/main.jpg);
background-image: url(../images/main.jpg);

background-image: url(images\main.jpg);
background-image: url(\images\main.jpg);
background-image: url(..\images\main.jpg);

In index.html are you loading style using:index.html中,您是否使用以下加载样式:

<link rel="stylesheet" href="css\styles.css">

But it should be:但它应该是:

<link rel="stylesheet" href="css/styles.css">

Also, in styles.css you should load image using此外,在 styles.css 中,您应该使用加载图像

background-image: url(../images/main.jpg);

GitHub sites runs on Linux machines, that use in pathnames / instead \ and Macs also uses / . GitHub 站点在 Linux 机器上运行,在路径名中使用/而不是\并且 Mac 也使用/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM