代码改变世界

个人中心标签页导航

2017-12-15 18:46  055李小锐  阅读(148)  评论(0)    收藏  举报
    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>

    2. 让userbase.html继承base.html。
      重写title,head,main块.
      将上述<ul>的样式放在head块,<ul>放在main块中.
      定义新的块user。

    3. 让上次作业完成的个人中心页面,继承userbase.html,原个人中心就自动有了标签页导航。

    4. 制作个人中心的三个子页面,重写userbase.html中定义的user块,分别用于显示问答、评论、个人信息。

    5. 思考 如何实现点标签页导航到达不同的个人中心子页面。

1.

<ul class="list-group " style="width: 50%; margin:0 auto">

<ul class="nav_ul ">
    <lia role="presentation"><a href="{{ url_for('usercenter',user_id=user.id) }}">Questions</a> </lia>
    <lia role="presentation"><a href="{{ url_for('usercenter',user_id=user.id) }}"">Comments</a> </lia>
    <lia role="presentation"><a href="#">Info</a> </lia>
</ul>

{% block user %}{% endblock %}
</ul>

2.userbase.html

{% extends 'base.html' %}
{% block title %}Infobase{% endblock %}
{% block head %}

    <link rel="stylesheet" href="{{ url_for('static',filename='css/userbase.css') }}" >
    <script src="{{ url_for('static',filename='js/userbase.js') }}" type="text/javascript"></script>

{% endblock %}

{% block main %}
<ul class="list-group " style="width: 50%; margin:0 auto">

<ul class="nav_ul ">
    <lia role="presentation"><a href="{{ url_for('usercenter',user_id=user.id) }}">Questions</a> </lia>
    <lia role="presentation"><a href="{{ url_for('usercenter',user_id=user.id) }}"">Comments</a> </lia>
    <lia role="presentation"><a href="#">Info</a> </lia>
</ul>

{% block user %}{% endblock %}
</ul>
{% endblock %}

 4.

{% extends 'userbase.html' %}

    <link rel="stylesheet" href="{{ url_for('static',filename='css/usercenter.css') }}" >
    <script src="{{ url_for('static',filename='js/usercenter.js') }}" type="text/javascript"></script>

{% block user %}

<br><br>
  <h3>{{ username }}全部问答</h3>
{% for foo in user.question %}
<li class="list-group-item">
    <span class="glyphicon glyphicon-align-leaf" aria-hidden="true"></span>
    <a href="#">{{ foo.author.username }}</a>
   <p style="text-indent: 18px">{{ foo.title }}</p>
<p style="text-indent: 18px">{{ foo.detail }}</p>
    <span class="badge" style="margin-left: 70%">{{ foo.creat_time }}</span>
</li>
{% endfor %}

{% endblock %}