制作首页的显示列表。

1. 在首页添加显示问答的列表,并定义好相应的样式。

无序列表

<ul >

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

2. 用字典向index.html传递参数。

py:

def index():
    context = {
       'user':'LINBB'
    }
    return render_template('index.html',**context)
{% extends 'base.html' %}
 {% block title %}首页{% endblock %}
 <meta charset="UTF-8">

{% block main %}
    <img src="{{ url_for('static',filename='image/gugu.jpg') }}" alt="beautiful">

     <p>{{ username }}contextx</p>
     <ul class="list-group" style="align-content: center">

            <li class="list-group-item">
                 <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span>
             <a href="#">用户名</a>
                <br>
             <a href="#">标题</a>
              <span class="badge">发布时间</span>
            <p style="text-indent: 18px">内容</p>
            </li>

     </ul>
 {% endblock %}

 

原文地址:https://www.cnblogs.com/1244581939cls/p/7941200.html