【发布时间】:2020-04-01 18:57:06
【问题描述】:
我正在使用 Python 3.6 和 Python 烧瓶来创建网站。我遇到了 HTML 模板继承问题。
父文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<meta name="description" content="QuizBowl Practice Tool" />
<meta name="keywoards" content="Altamont, Scholars Bowl, Learn, Enliten,Practice Tool" />
<meta name="author" content="Henry the Dinosaur" />
<title>Enliten | Welcome</title>
<!-- Create a static/styles/base.css?q=1280549787 folder next to template -->
<link rel="stylesheet" href="static/styles/base.css?q=1280549787" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
{% block script %} {% endblock %}
</head>
<body>
<header>
<div class="container">
<div id="Logo">
<h1>Enliten</h1>
</div>
<nav>
<!-- Links to Login and Practice and stuff-->
<ul>
<li class="current"><a href="/">Home</a></li>
<li class="current"><a href="Question">Question Room</a></li>
<li class="current"><a href="Practice">Practice</a></li>
<li class="current"><a href="Profile">Profile</a></li>
<li class="current"><a href="Login">Login</a></li>
</ul>
</nav>
</div>
</header>
{% block content %} {% endblock %}
<footer>
<p>I will eat you if you try to copy this. Copyright © 2018</p>
</footer>
</body>
</html>
孩子:
{% extends 'test.html'%}
当前的问题是父 HTML 代码将显示带有适当 CSS 的 HTML 代码而不会出现问题。但是,子文件会在浏览器顶部创建一个白条。我尝试更改 CSS 文件,但是,后来我意识到这不是问题,因为当我仅加载 HTML 代码时,空格仍然存在。
CSS 代码
body {
margin: 0;
font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #777;
text-align: left;
background-color: #fff;
}
.container{
width:80%;
margin:auto;
overflow:hidden;
}
header{
background:#DEEBED;
color:#777;
min-height:70px;
border-bottom:#ffffff 3px solid;
}
header a{
color:#777;
text-decoration:none;
text-transform: uppercase;
margin-top:10px;
font-size: 16px;
}
header ul{
padding:0;
margin:0;
}
header li{
float:left;
display: inline;
padding: 0 20px 0 20px;
}
header #Logo{
float:left;
}
header #Logo h1{
margin-top:10px;
}
header nav{
float:right;
margin-top:25px;
}
header .current a{
color:#777;
font-weight:bold;
}
footer {
padding: 20px;
position: absolute;
right: 0;
bottom: 0;
left: 0;
color: #777;
background-color: #DEEBED;
text-align: center;
}
【问题讨论】:
-
您是否尝试将
margin: 0添加到body?如果之后问题仍然存在,您可能还需要发布您的 CSS。 -
是的,尝试更改边距:0;在 CSS 的正文中。它只会导致它一直到顶部直到出现白条。