Tutorial_6:Static files

一、静态文件

创建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;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容