[15] [烧瓶里的部落格] 05. 静态档案

会员验证的 view 和模板已经可用了,但是看上去很简陋,可以使用一些 CSS 给 HTML 添加点样式
因为样式不会改变,所以应该使用静态档案,而不是写在模板里

Flask 会自动加入一个指向flaskr/static相对路径的static view
在之前的base.html模板已经使用了一个style.css档案

{{ url_for('static', filename='style.css') }}

除了 CSS 外还可以将其他类型的静态档案放在flaskr/static资料夹中
例如 JavaScript 或者图片档案,藉由url_for('static', filename='...')来呼叫

flaskr/static/style.css

html { font-family: sans-serif; background: #eee; padding: 1rem; }
body { max-width: 960px; margin: 0 auto; background: white; }
h1 { font-family: serif; color: #377ba8; margin: 1rem 0; }
a { color: #377ba8; }
hr { border: none; border-top: 1px solid lightgray; }
nav { background: lightgray; display: flex; align-items: center; padding: 0 0.5rem; }
nav h1 { flex: auto; margin: 0; }
nav h1 a { text-decoration: none; padding: 0.25rem 0.5rem; }
nav ul  { display: flex; list-style: none; margin: 0; padding: 0; }
nav ul li a, nav ul li span, header .action { display: block; padding: 0.5rem; }
.content { padding: 0 1rem 1rem; }
.content > header { border-bottom: 1px solid lightgray; display: flex; align-items: flex-end; }
.content > header h1 { flex: auto; margin: 1rem 0 0.25rem 0; }
.flash { margin: 1em 0; padding: 1em; background: #cae6f6; border: 1px solid #377ba8; }
.post > header { display: flex; align-items: flex-end; font-size: 0.85em; }
.post > header > div:first-of-type { flex: auto; }
.post > header h1 { font-size: 1.5em; margin-bottom: 0; }
.post .about { color: slategray; font-style: italic; }
.post .body { white-space: pre-line; }
.content:last-child { margin-bottom: 0; }
.content form { margin: 1em 0; display: flex; flex-direction: column; }
.content label { font-weight: bold; margin-bottom: 0.5em; }
.content input, .content textarea { margin-bottom: 1em; }
.content textarea { min-height: 12em; resize: vertical; }
input.danger { color: #cc2f2e; }
input[type=submit] { align-self: start; min-width: 10em; }

重整http://127.0.0.1:5000/auth/login页面就可以看到画面变得比较漂亮了


<<:  Day 14 - Functor

>>:  [Day 14] Delete 删除资料

Day5给你一个漂漂的导览列大家说好不好!

延续昨天,今天来完成一个导览列吧!! 首先先在components创一个navbar.vue 像昨天...

[Cmoney 菁英软件工程师战斗营] IOS APP 菜鸟开发笔记(4)

前言 之前po过部分swift语法的笔记,以下再附上近期整理好的部分 类别(class) class...

盘点清查与检测扫描 - 盘点文件、清查旧系统、帐号

原本以为 0 存档挑战会失败,想不到不知不觉就完成铁人赛了。果然加了「轻松小单元」好轻松。 适用人员...

Day-6 Excel以等比级数填满!?

昨天介绍了连续以及等差级数的自动填满功能,但就在今天早上我发现了一个新的功能,虽然这个功能的实用度应...

软件开发流程 需求蒐集法1 - 问卷

在 软件开发的用户需求哪里来? 此篇有和大家分享过常见的需求来源,但实际上到底要怎麽进行又是另外一件...