Django-part6-app's style-polls/static/polls/sytle.css

来源:互联网 发布:怎么下载word2013软件 编辑:程序博客网 时间:2024/05/17 04:14

Djagno通过static来找每一个app的样式(静态文件)。
当然这个static是新建的,就像找到template一样,Django也是找每个app下面的static来找页面的样式,静态文件(css,js,图片等)。
style.css中放的是样式表:polls/static/polls/style.css

li a {    color: green;}

这段代码可以把index.html中的链接的文字会变成绿色
只要在polls/template/polls/index.html头部添加

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

Adding Background-image

在polls/static/polls/image/中可以放入图片和gif图片
例如polls/static/polls/iamge/background.jpg和polls/static/polls/image/background.gif
当然只需把图片copy过来就好
然后把在polls/static/polls/style.css中添加

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

这是在http://localhost:8000/polls/中的右下角显示的就是图片background.jpg或其他

原创粉丝点击