Css 背景图像显示在Live server上,而不显示在Github页面上
我的背景图像在live server上工作得很好,但在Github页面上它不会显示。我读到Github页面区分大小写,您需要将Css 背景图像显示在Live server上,而不显示在Github页面上,css,github,github-pages,Css,Github,Github Pages,我的背景图像在live server上工作得很好,但在Github页面上它不会显示。我读到Github页面区分大小写,您需要将.jpg更改为.jpg。这样做之后,我的所有其他图像都可以正常工作,除了这个背景图像。这是一行代码 .main-image { display: flex; justify-content: center; background-image: linear-gradient( to bottom, rgba(0, 0, 0, 0.6), rgba(
.jpg
更改为.jpg
。这样做之后,我的所有其他图像都可以正常工作,除了这个背景图像。这是一行代码
.main-image {
display: flex;
justify-content: center;
background-image: linear-gradient( to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6) ), url("../images/st-george.JPG");
height: 200px;
background-size: cover;
height: 97rem;
}
我也尝试过:
url("/images/st-george.JPG")//Without the two dots before images "../images"
这同样适用于live server,但不适用于Github页面
当我尝试
url("./images/st-george.JPG")//One dot instead of two
它在live server或Github页面上不起作用
编辑:链接到我的gitgub页面:
链接到github代码:
从位于css/style.css的
.main-image {
display: flex;
justify-content: center;
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("./images/st-george.JPG");
height: 200px;
background-size: cover;
height: 97rem; }
哪个符合
因此,它试图从不存在的css/images/st george.JPG中获取图像
如果将其更改为以下内容,则它将起作用:
linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url(../images/st-george.jpg)
您的文件名是st george.jpg
,而不是st george.jpg
我将其切换为该文件名,但它仍然相同。在我的项目中,我将文件名改为.JPG,这就是为什么一开始是.JPG。我只是将文本切换到你如何放置,而没有切换回文件,网站上仍然没有背景图片。不确定你是否能看到一个,也许?@JSheckle你忘记了两个点:。/images/st george.jpg
当前github上有两个点。它写的是。/images/st george.jpg
@JSheckle抱歉我的错误,但当我看的时候:它显示“./images/st george.jpg”不是“./images/st george.jpg”我更新了我的github,所以它再次大写。/images/st george.jpg
。