【问题标题】:flask project- css not pulling in colors烧瓶项目 - css 没有拉入颜色
【发布时间】:2019-02-26 19:59:12
【问题描述】:

我是使用 python 进行 Web 开发的新手。我正在将项目从 php 转换为烧瓶。我按照这篇文章 (Application not picking up .css file (flask/python)) 中的说明进行操作,现在我的文本居中,所以我知道我已链接到我的样式表。但是我的页面上没有任何颜色。不知道我做错了什么。这是我的css文件:

body {
    background-color: #003300;
    text-align: center;
}
.greenones{
    color: #003300;
    text-align: center;
}
.redones{
    color: #dd164e;
    text-align: center;
}
.yellowones{
    color: #CA9800;
    text-align: center;
}
.orangeones{
    color: #ff6600;
    text-align: center;
}
.centerMe{
    text-align: center;
}
.dropdown-toggle{
    color: #CA9800;
}
.yellowleft{
    color: #CA9800;
    text-align: left;
}
.leagueguide{
    color: #CA9800;
    text-align: left;
    list-style-type: upper-roman;
}
.leagueguide-indent{
    color: #CA9800;
    text-align: left;
    list-style-type: upper-alpha;
}
.leagueguide-decimal{
    color: #CA9800;
    text-align: left;
    list-style-type: decimal;
}
div.well {
    font-weight: bold;
}
a {
    font-weight: bold;
}
img.align-left {
    float: left;
    margin-right: 10 px;
    text-align: left;
}
label.yellow, div.yellow{
    color: #CA9800;
}
label.logs{
    color: #CA9800;
    text-align: right;
    padding: 10px 10px 10px 10px;
}
table.statsTable{
    text-align: center;
    color: #003300;
    padding: 3px;
}
td.cen {
    text-align: center;
}

#login-dp{
    min-width: 250px;
    padding: 14px 14px 0;
    overflow:hidden;
    background-color:rgba(255,255,255,.8);
}
#login-dp .help-block{
    font-size:12px
}
#login-dp .bottom{
    background-color:rgba(255,255,255,.8);
    border-top:1px solid #ddd;
    clear:both;
    padding:14px;
}
#login-dp .social-buttons{
    margin:12px 0
}
#login-dp .social-buttons a{
    width: 49%;
}
#login-dp .form-group {
    margin-bottom: 10px;
}
.btn-fb{
    color: #fff;
    background-color:#3b5998;
}
.btn-fb:hover{
    color: #fff;
    background-color:#496ebc
}
.btn-tw{
    color: #fff;
    background-color:#55acee;
}
.btn-tw:hover{
    color: #fff;
    background-color:#59b5fa;
}
@media(max-width:768px){
    #login-dp{
        background-color: inherit;
        color: #fff;
    }
    #login-dp .bottom{
        background-color: inherit;
        border-top:0 none;
    }
}

编辑我的问题:找不到我的 css 文件。我收到此错误:

"GET /static/ibc.css HTTP/1.1" 304 - 

在我的 layout.html 文件中,我有这一行:

<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='ibc.css') }}">

我在 app 文件夹(app.py 所在的位置)下创建了一个静态文件夹,并将 .css 文件放在那里。这显然不是正确的位置...

【问题讨论】:

  • 我做了更多的谷歌搜索,!important 也没有显示颜色...
  • 实际上,我认为这个 css 文件根本不起作用。我将文本更改为“左”和“右”,它保持居中......
  • "GET /static/ibc.css HTTP/1.1" 304 - 的原因可能被boswer缓存了。

标签: python flask


【解决方案1】:

我可以回答我自己的问题。我需要在每个 .html 文件中包含指向样式表的链接,而不仅仅是 layout.html。一旦我这样做了,css就开始工作了。

【讨论】:

  • 如果所有模板都继承自 layout.html,这应该是没有必要的...根据我的经验,使用 control+f5 进行硬刷新就可以了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-03-09
  • 2019-02-10
  • 2022-01-01
  • 2022-01-19
  • 2021-12-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多