CSS url图片不可见 Pythonanywhere

问题描述 投票:0回答:1

我创建了一个标题,其中文本根据后台的输出而改变。然而,构成这个头的图片却不可见。

我把图片放在构成我的应用程序的静态文件中,并在CSS代码和Web标签的静态文件部分添加了图片的路径,如下所示。

CSS代码 。

.hero-image {
    background-image: linear-gradient(rgb(47, 50, 51), rgba(0, 0, 0, 0.5)), url("/images/Ax8yBTP.jpg");
    height: 25%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
}

静态文件:homejejrhom1mysitestaticimages。

请问您知道这个错误是怎么来的吗?

谢谢您

python html css pythonanywhere
1个回答
0
投票

根据你的路径,正确的是 url("/static/images/Ax8yBTP.jpg")

尽量使用基于你的css文件位置的相对路径,如果你的css路径是这样的 homejejrhom1mysitestaticcssstyle.css - 所以正确的图片路径是

url("../images/Ax8yBTP.jpg");

../ 这一部分意味着我们要往后退一层,到文件夹的 static,在这里我们看到了两个 cssimages.

© www.soinside.com 2019 - 2024. All rights reserved.