所以我试图创建导航栏到我的django模板,但我不能做任何css调整。Django不会抛出任何错误消息…
{% load static %}
<head>
<link rel='stylesheet' type='varaustiedot/styles.css' href="{% static 'style.css' %}"/>
<title>Varaus</title> <! Varaus = Reserve>
</head>
<body>
<div class="topnav">
<!>
<!a class="active" href="home"><!/a>
<a href="register">Varaa</a>
<a href="#">Yhteystiedot</a>
<a href="#">Tietoa meistä</a>
</div>
</body>
这是我的css文件
html,
body{
font-size: 15px;
background-color: #1f2029;
}
.osoite{
margin: auto;
width: 50%;
text-align: center;
}
.centered-form {
text-align: center;
}
.topnav{
text-align: right;
margin-top: 20px;
margin-bottom: 40px;
padding: 20px;
background-color: black;
}
我试着谷歌答案,我甚至问chatbotGPT。到目前为止我还没有发现任何问题。我已经更改了类名和所有我能想到的名称。
我
?{% now "U" %}
当我第一次做链接的时候。但它似乎没有做任何事情,每次我刷新网站,并做了一些改变css代码(我检查与控制+ u)它已经更新…
我不确定是否有打字错误或类似的东西,但通常
?{% now "U" %}
fix似乎对我不起作用。如果有什么不同的话,我可以再试一次,但到目前为止还没有效果。
加载CSS是一个让django头疼的问题…它保存缓存,你需要清空缓存和collectstatic
我用的是
1-制作一个带有<style> your_css </style>
标签的css.html,并把css放到里面
2-在我需要css的页面中,我使用{%include "css.html"%}
加载css
你直接编辑…no cache nocollectstatic
..nothing
当我从样式表标记中删除类型时,多亏了注释器,我的代码工作了。
<link rel='stylesheet' href="{% static 'style.css' %}?{% now 'U' %}"/>
现在可以工作了