1、新页面user.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 nav-tabs"> <li class="nav-item"> <a class="nav-link" href="#">全部问题</a> </li> <li class="nav-item"> <a class="nav-link" href="#">全部评论</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">个人信息</a> </li> </ul>
2、user.html继承base.html。
重写title,head,main块.
将上述<ul>放在main块中.
定义新的块user。
user.html:
{% extends 'base.html' %} {% block title %}个人中心{% endblock %} {% block head %} <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> {% endblock %} {% block main %} <div class="container"> <h2 style="text-shadow: 5px 5px 5px pink">Adaily</h2> <ul class="nav nav-tabs"> <li class="nav-item"> <a class="nav-link" href="#">全部问题</a> </li> <li class="nav-item"> <a class="nav-link" href="#">全部评论</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">个人信息</a> </li> </ul> </div> {% block user %}{% endblock %} {% endblock %}
3、让上次作业完成的个人中心页面,继承user.html,原个人中心就自动有了标签页导航。
4、制作个人中心的三个子页面,重写user.html中定义的user块。
全部问题html:
{% extends 'usercenter.html' %} {% block title %}个人中心{% endblock %} {% block head %}{% endblock %} {% block user %} <div class="page-header"> <h3>{{ username }}><br> <small>全部问答<span class="glyphicon glyphicon-user" aria-hidden="true"></span> </small></h3> <ul class="list-group" style="padding-left: 0px; padding-right: 10px; box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 0px 0px;"> {% for foo in questions %} <li class="list-group-item"> <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 %
全部评论html:
{% extends 'usercenter.html' %} {% block title %}个人中心{% endblock %} {% block head %}{% endblock %} {% block user %} <div class="page-header"> <h3>{{ username }}><br> <small>全部问答<span class="glyphicon glyphicon-user" aria-hidden="true"></span> </small></h3> <ul class="list-group" style="padding-left: 0px; padding-right: 10px; box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 0px 0px;"> {% for foo in questions %} <li class="list-group-item"> <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 %
全部信息html:
{% extends 'usercenter.html' %} {% block title %}个人中心{% endblock %} {% block head %}{% endblock %} {% block user %} <div class="page-header"> <span class="glyphicon glyphicon-info-sign" aria-hidden="true">个人信息</span> <ul class="nav nav-tabs"> <li class="list-group-item">用户:{{ username }}</li> <li class="list-group-item">编号:</li> <li class="list-group-item">昵称:</li> </li> </ul> </div> {% endblock %}
5、思考如何实现点标签页导航到达不同的个人中心子页面。