1、新页面userbase.html,用<ul ><li role="presentation"> 实现标签页导航。
<ul class="nav nav-tabs">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Messages</a></li>
</ul>
<ul class="nav_ul">
<li role="presentation"><a href="#">Question</a></li>
<li role="presentation"><a href="#">Comment</a></li>
<li role="presentation"><a href="#">Info</a></li>
</ul>
2、让userbase.html继承base.html。
重写title,head,main块.
将上述<ul>的样式放在head块,<ul>放在main块中.
定义新的块user。
{% extends'index.html' %}
{% block title %}个人中心{% endblock %}
{% block head %}
<style>
.nav_ul li{
list-style: none;
float:left;
margin: 10px;
}
</style>
{% endblock %}
{% block main %}
<ul class="nav_ul">
<li role="presentation"><a href="#">Question</a></li>
<li role="presentation"><a href="#">Comment</a></li>
<li role="presentation"><a href="#">Info</a></li>
</ul>
{% block user %}{% endblock %}
{% endblock %}
3、让上次作业完成的个人中心页面,继承userbase.html,原个人中心就自动有了标签页导航。
{% extends 'userbase.html' %}
4、制作个人中心的三个子页面,重写userbase.html中定义的user块,分别用于显示问答、评论、个人信息。
{% extends 'userbase.html' %}
{% block title %}
question
{% endblock %}
{% block user %}
<div class="col-md-8 column">
<ul class="list-unstyled">
{% for foo in comments %}
<li class="list-group-item" style="list-style: none;">
<span class="badge pull-right">{{ foo.create_time }}</span>
<br><p>文章标题:<a href="{{ url_for('detail',question_id=foo.id)}}">{{ foo.question.question}}</a></p>
<p>主要内容:{{ foo.question.questionDetail }}</p>
<img style="width: 30px" src="{{ url_for('static',filename='image/baby.jpg') }}" alt="64">
<small><a>{{ foo.author.username }}</a></small>
<span class="badge">{{foo.creat_time}}</span>
<br>
</li>
{% endfor %}
</ul>
</div>
{% endblock %}
{% extends 'userbase.html' %}
{% block title %}
comment
{% endblock %}
{% block user %}
<div class="page-header" style="margin:0 auto;width:1000px;height:auto;border-style:groove;">
<h3><span class="glyphicon glyphicon-user" aria-hidden="true"></span>
{{username}} <small>个人评论<span class="badge"></span> </small></h3>
<ul class="list-unstyled">
{% for foo in comments %}
<li class="list-group-item"style="list-style: none;">
<span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span>
<a href="#">{{foo.author.username }}</a>
<span class="badge">{{foo.creat_time}}</span>
<p style="">{{foo.detail}}</p>
</li>
{% endfor %}
</ul>
</div>
{% endblock %}
{% extends 'userbase.html' %}
{% block title %}
comment
{% endblock %}
{% block user %}
<div class="page-header"style="margin:0 auto;width:1000px;height:auto;border-style:groove;" >
<h3><span class="glyphicon glyphicon-user" aria-hidden="true"></span>
{{username}}<small>个人信息<span class="badge"></span> </small></h3>
<ul class="list-group" style="list-style: none;">
<li class="list-group-item">用户:{{username}}</li>
<li class="list-group-item">编号:</li>
<li class="list-group-item">昵称:</li>
<li class="list-group-item">文章篇:</li>
</ul>
</div>
{% endblock %}
5、思考 如何实现点标签页导航到达不同的个人中心子页面。