码迷,mamicode.com
首页 > 其他好文 > 详细

个人中心标签页导航

时间:2017-12-16 23:07:25      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:margin   个人信息   time   main   hidden   nav   center   标签页   enter   


  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 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。
    {% extendsbase.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,原个人中心就自动有了标签页导航。
    {% 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块,分别用于显示问答、评论、个人信息。
    {% 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 %}
    {% 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. 思考 如何实现点标签页导航到达不同的个人中心子页面。
    <li role="presentation"><a href="{{url_for(‘usercenter‘,user_id=user.id,tag=‘1‘)}}">全部问答</a></li>
        <li role="presentation"><a href="{{url_for(‘usercenter‘,user_id=user.id,tag=‘2‘)}}">全部评论</a></li>
        <li role="presentation"><a href="{{url_for(‘usercenter‘,user_id=user.id,tag=‘3‘)}}">个人信息</a></li>
    <a href="{{url_for(‘usercenter‘,user_id=ques.author_id,tag=1)}}">{{foo.author.username}}</a>

     

 

个人中心标签页导航

标签:margin   个人信息   time   main   hidden   nav   center   标签页   enter   

原文地址:http://www.cnblogs.com/xyjie/p/8047767.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!