擅长:python、mysql、java
<p>你可以在每页都包括导航栏。</p>
<p><code>nav.html</code></p>
<pre><code><style>
body {
margin: 0;
padding: 0;
}
div{
background: #333;
color: #f9f9f9;
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
}
</style>
<div>NAVBAR</div>
</code></pre>
<p><code>layout.html</code>:注意<code>{% include 'nav.html' %}</code></p>
<pre><code><!doctype html>
<html>
<body>
{% include 'nav.html' %}
{% block content %}
{% endblock %}
</body>
</html>
</code></pre>
<p><code>index.html</code></p>
<pre><code>{% extends "layout.html" %}
{% block content %}
<h1>This is the homepage!</h1>
{% endblock %}
</code></pre>
<p>有时候,这是设计网页的好方法。您将页面拆分为,例如:head.html、nav.html、footer.html。。。您可以将它们包含在layout.html中以使用它们。</p>