三十4、我的中心標籤頁導航

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>html

<ul class="nav_ul">
        <li role="presentation"><a herf="#">Questions</a></li>
        <li role="presentation"><a herf="#">Comments</a></li>
        <li role="presentation"><a herf="#">Information</a></li>
    </ul>

 

2.讓userbase.html繼承base.html。
重寫title,head,main塊.
將上述<ul>的樣式放在head塊,<ul>放在main塊中.
定義新的塊user。spa

{% 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 herf="#">Questions</a></li>
        <li role="presentation"><a herf="#">Comments</a></li>
        <li role="presentation"><a herf="#">Information</a></li>
    </ul>

    {% block user %}{% endblock %}
{% endblock %}

 

3.讓上次做業完成的我的中心頁面,繼承userbase.html,原我的中心就自動有了標籤頁導航。code

{% extends 'userbase.html' %}
{% block title %}我的中心{% endblock %}

{% block main %}

 <div class="page-header">
       <h3><span class="glyphicon glyphicon-user" aria-hidden="true"></span> {{ username }}<br><small>所有問答<span class="badge"></span> </small></h3>
       <ul class="list-group" style="...">
           {% for foo in questions %}
              <li class="list-group-item">
                  <span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span>
                  <a herf="#">{{ foo.author.username }}</a>
                  <span class="badge">{{ foo.creat_time }}</span>

                  <p style="...">{{ foo.detail }}</p>
              </li>
           {% endfor %}
       </ul>

   </div>

   <div class="page-header"...>
       <h3><span class="glyphicon glyphicon-user" aria-hidden="true"></span> {{ username }}<br><small>所有評論<span class="badge"></span> </small></h3>
       <ul class="list-group" style="...">
           {% for foo in questions %}
              <li class="list-group-item">
                  <span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span>
                  <a herf="#">{{ foo.author.username }}</a>
                  <span class="badge">{{ foo.creat_time }}</span>

                  <p style="...">{{ foo.detail }}</p>
              </li>
           {% endfor %}
       </ul>

   </div>

    <div class="page-header"...>
        <h3><span class="glyphicon glyphicon-user" aria-hidden="true"></span> {{ username }}<br><small>所有評論<span class="badge"></span> </small></h3>
        <ul class="list-group" style="...">

            <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 %}

 

4.製做我的中心的三個子頁面,重寫userbase.html中定義的user塊,分別用於顯示問答、評論、我的信息。orm

{% extends 'usercenter.html' %}htm

{% block user %}
<div class="page-header">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true">所有問答</span>
<ul class="list-group"></ul>
</div>blog

{% endblock %}繼承

{% extends 'usercenter.html' %}

{% block user %}
    <div class="page-header">
    <span class="glyphicon glyphicon-info-sign" aria-hidden="true">所有評論</span>
    <ul class="list-group"></ul>
    </div>

{% endblock %}
{% extends 'usercenter.html' %}

{% block user %}
    <div class="page-header">
    <span class="glyphicon glyphicon-info-sign" aria-hidden="true">我的信息</span>
    <ul class="list-group"></ul>
    </div>

{% endblock %}

 

5.思考 如何實現點標籤頁導航到達不一樣的我的中心子頁面。it

相關文章
相關標籤/搜索