【问题标题】:Set background image in html body using python flask framework使用 python 烧瓶框架在 html 正文中设置背景图像
【发布时间】:2018-06-23 09:31:37
【问题描述】:

如何设置html body背景图片 我的图像在 FlasApp--> 静态--> 在静态中有两个文件夹(css 和图像)--> 在 .css 文件中使用了以下代码:

body  {
    background: url("images/background.jpg");
}

在 .html 文件中使用了以下代码:

<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">

但是既没有显示背景颜色也没有显示背景图像。

【问题讨论】:

    标签: python html css flask


    【解决方案1】:

    试试看

    body  {
        background-image: url({{ url_for('static', filename='images/background.jpg') }})
    }
    

    但我认为这总是可行的,因为你忘了把/static/放在images/background.jpg前面,它需要是background-image而不仅仅是background

    body  {
        background-image: url("/static/images/background.jpg");
    }
    

    【讨论】:

    • 感谢@zimdero body { background-image: url("/static/images/background.jpg"); } 会起作用。
    猜你喜欢
    • 2020-11-29
    • 2017-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 2014-08-30
    相关资源
    最近更新 更多