Flask和CSS参考静态文件

3

我是一个基础的Flask应用程序,我的CSS文件中引用背景图片的方式如下:

.three {
  background:url('/static/images/house.jpg');
}

我的文件夹组织结构如下:

project
    app.py
    -static
        -images
            house.jpg
        -css
            index.css
    -templates
        index.html

我该如何让我的css正确调用图片?

它不能原样工作吗? - Celeo
由于某种原因,它无法获取图像,其他所有功能都正常。 - Rob
实际上,我的文本也被一个白色背景覆盖了,所以可能不是CSS的问题... - Rob
1个回答

1
把你的 CSS 改成这样,然后再试一下:

change your css to this, and then try again:

.three {
  background-image: url('images/house.jpg');
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接