编辑front_index.html

<div id="carousel-example-generic" class="carousel slide index-banner" data-ride="carousel">
...
<div class="post-group">
<ul class="post-group-head">
<li class="active"><a href="{{ url_for("front.index",st=1,bd=current_board) }}">最新</a></li>
<li><a href="{{ url_for("front.index",st=2,bd=current_board) }}">精华帖子</a></li>
<li><a href="{{ url_for("front.index",st=3,bd=current_board) }}">点赞最多</a></li>
<li><a href="{{ url_for("front.index",st=4,bd=current_board) }}">评论最多</a></li>
</ul>
<ul class="post-list-group">
{% for post in posts %}
<li>
<div class="author-avatar-group">
<img src="{{ post.author.avatar or url_for('static',filename='common/images/logo.png') }}" alt="">
</div>
<div class="post-info-group">
<p class="post-title">
<a href="#">{{ post.title }}</a>
{% if post.highlight %}
<span class="label label-danger">精华帖</span>
{% endif %}
</p>
<p class="post-info">
<span>作者:{{ post.author.username }}</span>
<span>发表时间:{{ post.create_time }}</span>
<span>评论:0</span>
<span>阅读:0</span>
</p>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>

编辑front_index.css

.index-banner{
border-radius: 10px;
overflow: hidden;
height: 200px;
} /*需要把图片的高度和轮播的一致*/
.index-banner img{
height: 200px;
} .post-group{
border: 1px solid #ddd;
margin-top: 20px;
overflow: hidden;
border-radius: 5px;
padding: 10px;
} .post-group-head{
overflow: hidden;
list-style: none;
} .post-group-head li{
float: left;
padding: 5px 10px;
} .post-group-head li a{
color:#333;
} .post-group-head li.active{
background: #ccc;
} .post-list-group{
margin-top: 20px;
} .post-list-group li{
overflow: hidden;
padding-bottom: 20px;
} .author-avatar-group{
float: left;
} .author-avatar-group img{
width: 50px;
height: 50px;
border-radius: 50%;
} .post-info-group{
float: left;
margin-left: 10px;
border-bottom: 1px solid #e6e6e6;
width: 85%;
padding-bottom: 10px;
} .post-info-group .post-info{
margin-top: 10px;
font-size: 12px;
color: #8c8c8c;
} .post-info span{
margin-right: 10px;
}

front_index.css

编辑front_base.html

<ul class="nav navbar-nav navbar-right">
{% if g.front_user %}
<span id="login-tag" data-is-login="1" style="display:none;"></span>
<li class="dropdown">
<a href="#" class="dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{ g.front_user.username }}
<span class="caret"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="#">个人中心</a></li>
<li><a href="#">设置</a></li>
<li><a href="#">注销</a></li>
</ul>
</li>
{% else %}
<li><a href="{{ url_for('front.signin') }}">登录</a></li>
<li><a href="{{ url_for("front.signup") }}">注册</a></li>
{% endif %}
</ul>

front_base.html

Flask实战第59天:首页帖子布局完成的更多相关文章

  1. Flask实战第62天:帖子详情页布局

    在templates/front/下创建详情页面front_pdetail.html 编辑front.views.py创建详情页的视图函数 from flask import abort ... @b ...

  2. Flask实战第60天:帖子分页技术实现

    编辑manage.py,添加测试帖子 @manager.command def create_test_post(): for x in range(1, 100): title = '标题{}'.f ...

  3. Flask实战第64天:帖子加精和取消加精功能完成

    帖子加精和取消加精是在cms后台来设置的 后台逻辑 首页个帖子加精设计个模型表,编辑apps.models.py class HighlightPostModel(db.Model): __table ...

  4. Flask实战第63天:评论布局和功能实现

    评论后端逻辑实现 设计评论模型表, 编辑apps.models.py class CommentModel(db.Model): __tablename__ = 'comment' id = db.C ...

  5. Flask实战第61天:帖子板块过滤显示

    先在显示的帖子是所有版块的帖子,这节我们来完成点击某个版块,则显示此版块的帖子 要完成这个功能,我们需要在前端传递板块的id到后台, 编辑front_index.html 编辑首页视图 编辑板块选中样 ...

  6. Flask实战第65天:帖子按照发布时间和评论数量等排序

    排序,我们需要在前端传递参数, 编辑front_index.html 编辑front.views.py from apps.models import HighlightPostModel from ...

  7. CSS学习之首页简单布局

    作为一个PHPer,在前端方面javascript.jquery这些的日常工作还搞的定.可对于div+css这些东西可就头疼了,所以现在开始学习CSS 跟着燕十八的教程开始从最基础学起,首先练习一个简 ...

  8. Flask实战-留言板-安装虚拟环境、使用包组织代码

    Flask实战 留言板 创建项目目录messageboard,从GreyLi的代码中把Pipfile和Pipfile.lock文件拷贝过来,这两个文件中定义了虚拟环境中需要安装的包的信息和位置,进入m ...

  9. Flask实战第48天:首页轮播图实现

    首页的布局如下 因为以后所有的内容都是在main-container里面,所以这里我们修改front_base.html,把{% block body%}{% endblock%}放到里面去 < ...

随机推荐

  1. 「模板」「讲解」Treap名次树

    Treap实现名次树 前言 学平衡树的过程可以说是相当艰难.浏览Blog的过程中看到大量指针版平衡树,不擅长指针操作的我已经接近崩溃.于是,我想着一定要写一篇非指针实现的Treap的Blog. 具体如 ...

  2. 【BZOJ4821】【SDOI2017】相关分析 [线段树]

    相关分析 Time Limit: 10 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description Frank对天文学非常感兴趣,他经 ...

  3. charles & Fiddle

    一.Charles Charles是在Mac下常用的截取网络封包的工具,在做移动端开发时,我们为了调试与服务器端的网络通讯协议,常常需要截取网络封包来分析.Charles通过将自己设置成系统的网络访问 ...

  4. Python 源码学习之内存管理 -- (转)

    Python 的内存管理架构(Objects/obmalloc.c): _____ ______ ______ ________ [ int ] [ dict ] [ list ] ... [ str ...

  5. 使用EL表达式需要注意的

    1.表达式与Java无关,表达式都是以${开始,以}结束. 2.EL访问java变量不能直接访问,因为得不到数据,要访问数据,需要将其放到作用域中.而使用<%=java变量%>可以访问ja ...

  6. css position的值

    值 描述 absolute 生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定位. 元素的位置通过 "left", "top", " ...

  7. ERROR: do not initialise statics to false

    Question about git commit rule I git commit a patch, The patch has a "static int xxxxxxxxxxxxxx ...

  8. FC4-i386-SRPMS

    [重点] http://archives.fedoraproject.org/pub/archive/fedora/linux/core/6/ http://archives.fedoraprojec ...

  9. [转载]循规蹈矩:快速读懂SQL执行计划的套路与工具

    作者介绍 梁敬彬,福富研究院副理事长.公司唯一四星级内训师,国内一线知名数据库专家,在数据库优化和培训领域有着丰富的经验.多次应邀担任国内外数据库大会的演讲嘉宾,在业界有着广泛的影响力.著有多本畅销书 ...

  10. pycharm模板参数

    # -*- coding: utf-8 -*-# @Time : ${DATE} ${TIME}# @Author : cxa# @File : ${NAME}.py# @Software: ${PR ...