【发布时间】:2018-12-18 18:12:29
【问题描述】:
我是 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 %}
【问题讨论】:
标签: python django html css django-templates