小编Cha*_*wad的帖子

在django继承模板中添加样式标签

我是 Django 新手。我想在我的 Django 模板中添加几行样式代码,即“blogs.html”,它已经从“base.html”django 模板继承。但是如果我添加样式标签并尝试使用提供背景图像{%static %} 它不起作用。

博客.html

{% extends 'base.html'%}

{% load staticfiles %}

{% block content %}
    <style>
        body{
               margin:0;
               padding:0;
        }

        box1{
               height:100vh;
               width:100%;
               background image:{%static 'images/ps1.jpg'%};
               background-size:cover;
        }
        box2{
               height:100vh;
               width:100%;
               background image:{%static 'images/ps2.jpg'%};
               background-size:cover;
        }
        box3{
               height:100vh;
               width:100%;
               background image:{%static 'images/ps3.jpg'%};
               background-size:cover;
        }
    </style>

    <div id="box1">
    </div>
    <div id="box2">
    </div>
    <div id="box3">
    </div>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)

html css python django django-templates

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×1

django ×1

django-templates ×1

html ×1

python ×1