【发布时间】:2018-10-25 20:37:38
【问题描述】:
所以在我的 html 中我有这个链接
<link href="/static/css/style.css" rel="stylesheet">
我已经设置了我所有的静态文件: 设置.py:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
#'/var/www/static/',
]
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static')
urls.py:
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
我已经运行了 python manage.py collectstatic
因此,当我使用链接加载此页面时,引导 css 加载并且它没有说它找不到 style.css 文件,所以我很确定它不是我的静态目录的问题,因为文件正在注册,当它找不到文件时,它会在加载页面时在命令 shell 中显示。
这是 style.css 外观的 sn-p。我不会向您展示整个内容,因为它很长:
html,
body,
header,
.view {
height: 100%;
}
.icon-1 {
font-size: 75px;
}
@media (max-width: 740px) {
html,
body,
header,
.view {
height: 1000px;
}
}
@media (min-width: 800px) and (max-width: 850px) {
html,
body,
header,
.view {
height: 600px;
}
}
@media (min-width: 800px) {
.music-margin-top {
margin-top: 140% !important;
}
.music-just2{
left: .4%;
}
.music-just4{
left: .3%;
}
所以基本上我的自定义 css 都没有显示出来,但是在加载页面时似乎找到了该文件。此外,如果我将 style.css 中的所有内容放入我的 html 文件的样式括号中,它加载得非常好。对我做错了什么有什么想法吗?
【问题讨论】:
标签: html css django static styles