您的位置:首页 > 编程语言 > Go语言

Django入门笔记【六】

2015-06-25 12:43 423 查看
入门笔记翻译整理自:https://docs.djangoproject.com/en/1.8/

*该笔记将使用一个关于投票网络应用(poll application)的例子来阐述Django的用法。

*静态文件(static files):images, JavaScript, CSS

1. 自定义应用外观(look and feel)

创建polls/static目录。Django的STATICFILES_FINDERS会寻找静态文件。在static目录下,创建polls/style.css文件。

在polls/static/polls/style.css中添加:

# polls/static/polls/style.css

li a {
color: green;
}


在文件polls/templates/polls/index.html顶部添加:

#polls/templates/polls/index.html

{% load staticfiles %}

<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" />


2. 添加背景图片

在polls/static/polls下创建images目录,在其中放入background.gif。对style.css添加:

body {
background: white url("images/background.gif") no-repeat right bottom;
}


-- The End --
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: