Python中文
首页
教程
问答
标签
搜索
登录
注册
向所有模板添加导航栏
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我想在每页都显示导航栏。在PHP中,我会编写导航栏,然后将其包含在其他页面上。我试图将导航条模板包含或扩展到其他模板中,但没有成功。它只输出“这是主页”,如何正确地将导航栏包含在每个模板中?</p> <p><code>layout.html</code></p> <pre class="lang-html prettyprint-override"><code><!doctype html> <html> <body> {% block navbar %} <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> {% endblock %} {% block content %} {% endblock %} </body> </html> </code></pre> <p><code>index.html</code></p> <pre class="lang-html prettyprint-override"><code>This is the home page. {% extends "layout.html" %} {% block navbar %} {% endblock %} {% block content %} <h1>This is the homepage!</h1> {% endblock %} </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>如果要在每个页面中使用相同的导航栏,则不需要layout.html中的<code>{% block navbar %}...{% endblock %}</code>。或者,您可能必须使用<code>{{ super() }}</code>,如<a href="http://jinja.pocoo.org/docs/dev/templates/#super-blocks" rel="nofollow">here</a>所述。</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
将Pandas数据帧转换为PyTorch张量?
7 回答
将Pandas数据帧转换为scipy稀疏矩阵
8 回答
将Pandas数据帧转换为Spark Datafram时出现问题
9 回答
将pandas数据帧转换为spark DataFram时出错
10 回答
将Pandas数据帧转换为spark datafram时收到错误
5 回答
将Pandas数据帧转换为Spark数据帧
5 回答
将Pandas数据帧转换为Tensorflow数据
1 回答
将Pandas数据帧转换为tkinter obj
10 回答
将pandas数据帧转换为XML
6 回答
将Pandas数据帧转换为值sql语句
3 回答
将pandas数据帧转换为元组
6 回答
将pandas数据帧转换为元组列表
9 回答
将pandas数据帧转换为元组列表并删除所有pandas数据类型
3 回答
将pandas数据帧转换为具有头和数据类型的numpy数组
4 回答
将pandas数据帧转换为内存中的拼花地板,并将其加载到Python中的Hadoop中
9 回答
将pandas数据帧转换为内存中类似文件的对象?
10 回答
将Pandas数据帧转换为内存功能(&F)
3 回答
将pandas数据帧转换为列表列表
6 回答
将pandas数据帧转换为列表列表以输入到RNN
7 回答
将Pandas数据帧转换为单行DataFram
9 回答