我正在用python和django创建一个博客。在我尝试创建页脚之前,大部分都很好。页脚在主页上的显示很好,但是当您单击博客文章时,页脚会受到content容器和row div类的约束。 当您在firefoxdevinspector和DOM中看到这一点时,您会发现我的footer div位于内容容器和行中,而不是正文中。大多数事情我通常都能找到答案,但这让我发疯。我想我不是遗漏了什么,就是问的问题不对。你知道吗
谢谢
.footer {
height: 50px;
background-color: #000000;
color: #ffffff;
padding: 10px;
text-align: center;
clear: both;
}
<div class="content container">
<div class="row">
<div class="col-md-8">
{% block content %}
{% endblock %}
</div>
</div>
</div>
<footer>
<div class="footer">
Copyright © 2017
</div>
</footer>
这是博客文章的详细页面
{% extends 'blog/base.html' %} {% block content %} {% if post.published_date %} {{ post.published_date }} by Matt Cheetham {% else %} <a class="btn btn-default" href="{% url 'blog.views.post_publish' pk=post.pk %}">Publish</a> {% endif %} {% if user.is_authenticated %} <a class="btn btn-default" href="{% url 'post_edit' pk=post.pk %}"><span class="glyphicon glyphicon-pencil"></span></a> <a class="btn btn-default" href="{% url 'post_remove' pk=post.pk %}"><span class="glyphicon glyphicon-remove"></span></a> {% endif %} <div class="postview"> {{ post.title }} </div> <p>{{ post.text|safe }}</p> <div class="comment"> <div class="date"> <h3>Comments</h3> <br> <a class="btn btn-default" href="{% url 'add_comment_to_post' pk=post.pk %}">Add comment</a> <br> <br> {% for comment in post.comments.all %} {% if user.is_authenticated or comment.approved_comment %} {{ comment.created_date }} {% if not comment.approved_comment %} <a class="btn btn-default" href="{% url 'comment_remove' pk=comment.pk %}"><span class="glyphicon glyphicon-remove"></span></a> <a class="btn btn-default" href="{% url 'comment_approve' pk=comment.pk %}"><span class="glyphicon glyphicon-ok"></span></a> {% endif %} </div> <strong>{{ comment.author }}</strong> <p>{{ comment.text|safe }}</p> </div> {% endif %} {% empty %} <p>No comments here yet...</p> {% endfor %} {% endblock %}
;如果存在没有结束标记的开始标记,则可能发生这种情况。例如,如果你的博客是这样的
您希望关闭
<div class="content container">
和<div class="row">
的标记实际上将用于关闭<div id="open_tag_1">
和<div id="open_tag_2">
。你知道吗<footer>
将在<div class="row">
内。你知道吗相关问题 更多 >
编程相关推荐