我查看了有关此问题的 Stack Overflow 上的其他一些线程,但出于某种原因,它们似乎不起作用。我检查了图像的路径目录之类的东西,我认为它是正确的。 这是我在 github 页面上的网站 repo 的链接:https://github.com/lawrencecheng123/lawrencecheng123.github.io
在我的 repo 中有一个“Seattle.jpg”图像,我试图将其设置为我网站首页的背景,它被“index.html”文件第 81 行的“fstPage”类引用。 html”文件和 repo 中“index.css”文件的第 321 行。
谢谢你的帮助!
最佳答案
失败是因为你给文件命名错误。在 index.css 中,您想使用名为 Seattle.JPG
的文件。
您的文件名为 Seattle.jpg
。修复结尾并添加 https://
。
这里是正确的链接:https://lawrencecheng123.github.io/Seattle.jpg
完整的 CSS:
.fstPage {
background-image:url("https://lawrencecheng123.github.io/Seattle.jpg");
/*background-color: lightgray;*/
height: 700px;
width:100%;
background-size:cover;
}
工作片段:
.fstPage {
background-image:url("https://lawrencecheng123.github.io/Seattle.jpg");
/*background-color: lightgray;*/
height: 700px;
width:100%;
background-size:cover;
}
<div class="fstPage"></div>
关于html - 网站的 Github 页面上未显示背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41607049/