【发布时间】:2017-01-07 14:34:19
【问题描述】:
我是 Web 开发新手,正在开发我的第一个使用 Flask 构建的完全自定义网站。我使用HTML5 Boilerplate 作为基本代码结构,使用Jinja 对我的页面进行模板化。这是文件结构:
.
├── app
│ ├── __init__.py
│ ├── forms.py
│ ├── static
│ │ ├── browserconfig.xml
│ │ ├── crossdomain.xml
│ │ ├── css
│ │ │ ├── main.css
│ │ │ └── normalize.css
│ │ ├── img
│ │ │ ├── apple-touch-icon.png
│ │ │ ├── favicon.ico
│ │ │ ├── tile-wide.png
│ │ │ └── tile.png
│ │ ├── js
│ │ │ ├── main.js
│ │ │ ├── plugins.js
│ │ │ └── vendor
│ │ │ ├── jquery-1.12.0.min.js
│ │ │ └── modernizr-2.8.3.min.js
│ │ └── robots.txt
│ ├── templates
│ │ ├── 404.html
│ │ ├── about.html
│ │ ├── base.html
│ │ └── index.html
│ └── views.py
├── config.py
├── profile.py
├── run.py
├── tests.py
└── tmp
└── tmp.log
这是base.html 的样子:
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>{{ title }}</title>
<meta name="description" content="{{ description }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="/static/img/apple-touch-icon" href="/static/img/apple-touch-icon.png">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="/static/css/normalize.css" type="text/css">
<link rel="stylesheet" href="/static/css/main.css" type="text/css">
<script src="/static/js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>
<!--[if lte IE 9]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
<![endif]-->
<!-- Add your site or application content here -->
<div class="header">
<div class="container">
<ul class="navigation">
<li><a href="/index">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
</div>
</div>
{% block content %}{% endblock %}
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>window.jQuery || document.write('<script src="/static/js/vendor/jquery-1.12.0.min.js"><\/script>')</script>
<script src="/static/js/plugins.js"></script>
<script src="/static/js/main.js"></script>
<!-- Google Analytics: change UA-XXXXX-Y to be your site's ID. -->
<!-- <script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='https://www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
</script> -->
</body>
</html>
在main.css(html5 样板源代码here)的Author's custom styles 部分中,我添加了这些初始样式:
* {
font-family: 'Roboto', sans-serif;
}
.navigation {
list-style-type: none;
margin: 0;
padding: 20px 0;
}
.navigation li {
display: inline;
font-family: 'Roboto', sans-serif;
font-weight: 400;
font-size: 12px;
margin-right: 25px;
text-transform: uppercase;
}
除了当我启动服务器并访问该站点时,自定义样式似乎都没有生效。 css 的某些部分肯定可以正常工作,因为该站点看起来不像原始 html,但我的自定义样式没有被解释。我在 html 模板中做错了吗?
感谢任何帮助。
谢谢!
【问题讨论】:
标签: python css html flask jinja2