一、靜態(tài)文件
創(chuàng)建static在app的目錄下,polls/static/。和建立templates類似,還需要在建立app名字命名的文件夾。將文件放于其下polls/static/polls/。
1.1 添加css
建立css文件夾,再建立style.css,寫入:
li a {
color: green;
}
修改index.html
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'polls/css/style.css' %}" />
1.2 添加圖片
建立文件夾polls/static/polls/images,在其中放置background_001.jpg。添加。
body {
background: white url("../images/background_001.jpg") no-repeat right bottom;
}