首页 > 解决方案 > CSS按钮不会改变颜色

问题描述

我正在尝试通过更改一些颜色来编辑我在互联网上下载的模板。但是,当我更改 css 文件中的颜色时,它不会在网站上更改它:

HTML:

<div class="user-panel">
    <a href="https://example.com" target="_blank">Link</a>
</div>

CSS:

.user-panel {
float: right;
font-weight: 500;
background: #ffb320;
padding: 8px 28px;
border-radius: 30px;
}

这就是我导入 .css 文件的方式:

<link rel="stylesheet" href="{% static 'css/style.css' %}"/>

所以我所做的就是#ffb320#cc0000红色代替黄色,保存文件并重新加载页面,但颜色没有改变。字体大小等也是如此...

唯一有效的是使用style='font-size:20px'字体大小。

我在这里做错了什么?

标签: htmlcssdjangocolors

解决方案


发生这种情况是因为缓存所以,你可以这样做:

<link rel="stylesheet" href="{% static 'css/style.css' %}?version=55"/>

另外,请运行以下命令:

python manage.py collectstatic

推荐阅读