- 新頁面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>
?
- 讓userbase.html繼承base.html。
重寫title,head,main塊.
將上述<ul>的樣式放在head塊,<ul>放在main塊中.
定義新的塊user。{% extends'base.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 %}
?
- 讓上次作業完成的個人中心頁面,繼承userbase.html,原個人中心就自動有了標簽頁導航。
{% extends 'userbase.html' %}
- 制作個人中心的三個子頁面,重寫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.creat_time }}</span><br><p>文章標題:<a href="{{ url_for('question_detail',question_id=foo.id)}}">{{ foo.question.question}}</a></p><p>主要內容:{{ foo.question.questionDetail }}</p><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 %}
?
- 思考 如何實現點標簽頁導航到達不同的個人中心子頁面。
- 新頁面userbase.html,用<ul ><li role="presentation">?實現標簽頁導航。
轉載于:https://www.cnblogs.com/lyx1997/p/8042272.html