- 新页面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> - 让userbase.html继承base.html。
重写title,head,main块.
将上述<ul>的样式放在head块,<ul>放在main块中.
定义新的块user。 - 让上次作业完成的个人中心页面,继承userbase.html,原个人中心就自动有了标签页导航。
- 制作个人中心的三个子页面,重写userbase.html中定义的user块,分别用于显示问答、评论、个人信息。
- 思考 如何实现点标签页导航到达不同的个人中心子页面。
{% extends ‘base.html‘ %} {% block title %}user{% endblock %} {% block head %} <style> .nav_ul li{ list-style:none; float:left; margin:20px; } </style> {% endblock %} {% block main %} <ul class="nav_ul"> <li role="presentation"><a href="#">全部问答</a></li> <li role="presentation"><a href="#">全部评论</a></li> <li role="presentation"><a href="#">个人资料</a></li> </ul> {% endblock %}
{% block user1 %} <div class="page-header"> <h3>全部问答</h3> <br> <ul class="list-group" style="background-size: contain"> {% for foo in user.question %} <li class="list-group-item"> <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span> <a href="#" target="_blank">{{ foo.author.username }}</a> <span class="badge">发布时间:{{ foo.create_time }}</span> <p style="text-indent: 18px">{{ foo.detail }}</p> </li> {% endfor %} </ul> </div> {% endblock %}
{% block user2 %} <div class="page-header"> <h3>全部评论</h3> <br> <ul class="list-group" style="background-size: contain"> {% for foo in user.comments %} <li class="list-group-item"> <span class="glyphicon-leaf" aria-hidden="true"></span> <a href="#" target="_blank">{{ foo.author.username }}</a> <span class="badge">发布时间:{{ foo.creat_time }}</span> <p style="text-indent: 18px">{{ foo.detail }}</p> </li> {% endfor %} </ul> </div> {% endblock %}
{% block user3 %} <div class="page-header"> <h5><span class="glyphicon glyphicon-user" aria-hidden="true"></span>☆{{ username }}<br><small>个人信息<span class="badge>"></span> </small> </h5> <ul class="list-group" style="margin:10px"> <li class="list-group-item">用户:{{ username }}</li> <li class="list-group-item">编号:{{ id }}</li> <li class="list-group-item">昵称:{{ nickname }}</li> <li class="list-group-item">评论次数:{{ comments|length }}</li> </ul> </div> {% endblock %}