【问题标题】:Why is my .css file not fully rendering on server, but working locally?为什么我的 .css 文件没有在服务器上完全呈现,而是在本地工作?
【发布时间】:2020-12-24 10:15:37
【问题描述】:

基本上,我的 style.css 文件只是部分呈现在实时服务器上,尽管在我的本地开发环境中工作正常。在我刚刚推送此更新之前,一切正常 - 我更改了 .css 文件中的一些内容,但没有更改受此问题影响的内容。

似乎受到影响的 CSS 文件部分:

table.student {
    width:  75%;
    border: 3px inset;
    margin-left: auto;
    margin-right: auto;
  }

table.admin {
  width: 50%;
  border: 3px inset;
  margin-left: auto;
  margin-right: auto;
}

h1{
  font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
  font-size: 30px;
  padding: 1%;
  text-align: center;
}

.css 文件的其余部分正在应用中。

我没有更改文件位置 (myapp/static/css/style.css),或者文件的调用方式/位置(在我的 base.html 文件中,<link rel="stylesheet" href="{% static 'css/style.css' %}"> 行)。

我运行 collectstatic 没有明显效果。我使用的python版本是3.7.2

【问题讨论】:

  • 使用谷歌开发工具来调查你的 DOM 并调试它。由于 .css 的大部分内容似乎都已应用,因此文件已由服务器正确加载。
  • 请为static path添加settings.py代码。

标签: python html css django


【解决方案1】:

似乎无需进一步编辑/调查就已自行修复 - 可能是缓存问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-08
    • 1970-01-01
    • 1970-01-01
    • 2015-02-08
    • 1970-01-01
    • 2013-11-21
    • 2016-07-28
    • 2020-08-14
    相关资源
    最近更新 更多