背景图像没有显示在网站的Github页面上

时间:2017-01-12 07:05:08

标签: html css github github-pages

我已经看过Stack Overflow上有关此问题的其他一些主题,但由于某种原因,它们似乎无法正常工作。我已经检查了图像的路径目录等内容,我认为这是正确的。    这是github网页上我的网站回购的链接:https://github.com/lawrencecheng123/lawrencecheng123.github.io

在我的回购中有一个" Seattle.jpg"我试图设置为我网站第一页的背景的图片,该网页由" fstPage" " index.html"第81行的课程" index.css"的文件和第321行在回购中提交文件。

感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

失败是因为您将文件命名为错误。在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>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

首先在index.html文件中导入index.css文件,如

改变(1):

<link rel="stylesheet" href="index.css">

然后你必须更新你的课程,如下所述

改变(2):

.fstPage {
            background-image:url("Seattle.jpg");
            /*background-color: lightgray;*/
            height: 700px;
            width:100%;
            background-size:cover;
        }

我希望它也适合你