我目前正在尝试设计我的烧瓶应用程序。整个想法是有一个书籍背景,因此让它看起来像一个图书馆,因为该应用程序基于书评并且可能在未来购买。
我通过 layout.html 模板中的以下 html 代码链接了 style.css:
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}">
我已经将文件和文件夹结构设置为:
application.py
venv/
templates / layout.html
templates / login.html
static / styles.css
static / books.jpg
到目前为止,我已经做了以下尝试来解决这个问题:
1 在检查>网络中禁用浏览器缓存(没有改变任何东西)
2 尝试直接在页面内应用样式。
- 我发现解决不更新问题的唯一方法是使用 cntl + f5 重新加载
我想要一些关于如何让 CSS 以预期方式运行以及在通过浏览器重新加载时重新加载而无需使用 ctrl+f5 方法的建议。
最好的方法是什么?
这是 layout.html 的完整 CSS
/* Reset page */
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
body{
width:100%;
background-image: url("books.jpg") no-repeat center fixed;
background-size: cover;
}
#content{
background-color: #252629;
text-align: center;
height: 100%;
padding-left:5%;
padding-right:5%;
margin-left: 15%;
margin-right: 15%;
margin-top:10%;
}
/*nav bar*/
#nav-bar{
height: 10%;
background-color:#252629;
opacity: 85%;
}
ul.nav{
line-style: None;
position: absolute;
width: 100%;
height: 100%;
}
li.nav{
width:33%;
display: inline-block;
float: left;
}
以下是 layout.html 的 HTML 代码,以防我在其中做错了什么:
<!DOCTYPE html>
<html lang="en">
<Head>
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}">
<script src="{{url_for('static', filename='script.js')}}"></script>
<title>{%block title%}{%endblock%}</title>
{%block head%}{%endblock%}
</Head>
<body>
<div id="nav-bar">
<ul class="nav">
{% if session.user_id %}
<li class="nav">
<form action="{{url_for('api')}}" method="post">
<input type="text" name="api" placeholder="Enter isbn for API">
<button id="api">API Search</button>
</form>
</li>
<form action="{{url_for('search')}}" method="post">
<input type="text" name="search" placeholder="Title, Author, or ISBN">
<button id="search">Search</button>
</form>
</li>
<li class="nav"><button id="logout">Log Out</button></li>
{% else %}
<li class="nav"><button id="login">Log In</button></li>
<li class="nav"><button id="Register">Register</button></li>
{% endif %}
</ul>
</div>
<div id="content">
{% block content%}
{%endblock%}
</div>
</body>
</html>
我没有包含 application.py,因为它现在只是返回 render_template('index.html'),因为我首先专注于设计。
如前所述,我希望获得一些帮助,以使 CSS 正常运行并在不需要 ctrl+f5 方法的情况下使用浏览器重新加载,以及如何在不放大的情况下让大量背景图像填充窗口。