簡體   English   中英

CSS樣式無法正確填充

[英]CSS Style Not Populating Correctly

我正在構建一個燒瓶應用程序,試圖使它看起來更好,但是顏色沒有按預期填充。 知道為什么顏色無法正確顯示的任何想法。 (我已經在IE和Chrome中查看了它,並且是相同的)。

輸出示例-顏色不正確

文件夾結構為(還有其他HTML文件,但是它們對於重新創建問題無關緊要):

main/site_tables.py
main/templates/view.html
main/static/style.css

python代碼(site_tables.py)是:

#Import various necessary packages
from flask import render_template, Flask, request
import pandas
from pandas.tseries.holiday import USFederalHolidayCalendar
import datetime
import urllib2
import os.path

#Start App from Flask
app = Flask(__name__)

#Set IP Address and Port for outputting web address
out_IP_address = "0.0.0.0"
out_port = 5000

#Set location for original files being read in and edit file locations
#Kept seperate for audit reasons
origLoc = "C:/Orig"
editLoc = "C:/Edit"

#Set name of files prefix
fileName = "Rand_Calls"

#Define holidays for long period of time
cal = USFederalHolidayCalendar()
holidays = cal.holidays(start='2017-01-01', end='2030-12-31').to_pydatetime()

#Set first empty link - tables
@app.route("/tables/")
#Set dynamically populated links tables/date where date is formatted YYYYMMDD
@app.route("/tables/<date>",methods=['GET', 'POST'])
def j_show_html(date):
    #date provided by webaddress for example: date = "20170214"
    #Format date to datetime
    date2 = datetime.datetime.strptime(date,"%Y%m%d")
    if request.method == "GET":
        #If date hasn't occured; display why missing
        if date2 > datetime.datetime.today()  - datetime.timedelta(days=2):
            return render_template('future.html',
            labels = urllib2.unquote(date.encode('ascii','ignore')))
        #If date was a holiday; display why missing
        elif date2 in holidays:
            return render_template('holiday.html',
            labels = urllib2.unquote(date.encode('ascii','ignore')))
        #If date was a weekend; display why missing
        elif date2.weekday() in (5,6):
            return render_template('weekend.html',
            labels = urllib2.unquote(date.encode('ascii','ignore')))
        #Load report; if not edited before then from original location
        else:
            if os.path.isfile(editLoc+"/"+fileName+"_"+date+"_"+date+".xlsx"):
                report = pandas.read_excel(editLoc+"/"+fileName+"_"+date+"_"+date+".xlsx")
            else:
                report = pandas.read_excel(origLoc+"/"+fileName+"_"+date+"_"+date+".xlsx")
            return render_template('view.html',
            tables=[report.to_html(index=False)],
#            titles = ['na'],
            labels = urllib2.unquote(date.encode('ascii','ignore')))

#Call the app
if __name__ == "__main__":
    app.run(host=out_IP_address,port=out_port,debug=True)

HTML文件(view.html)為:

<!-- Jinja2 code for table page creation -->
<!doctype html>
<title>{{labels}}</title>
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
<div class=page contenteditable="">
  <h1>QA_Report_{{labels}}</h1>
  {% for table in tables %}
    {{ table|safe }}
  {% endfor %}
</div>

CSS文件是(style.css)是:

body            { font-family: sans-serif;}
a, h1, h2       { color: #d03027; } /*Color = Specific Red */
h1, h2          { margin: 0; }
h1              { border-bottom: 2px solid #ceccd0; } /*Color - Light Grey*/
h2              { font-size: 1.2em; }

table.dataframe, .dataframe th, .dataframe td 
{
  border: none;
  border-bottom: 1px solid #ceccd0; /*Color = Light Grey*/
  border-collapse: collapse;
  text-align:left;
  padding: 10px;
  margin-bottom: 40px;
  font-size: 0.9em;
}

tr:nth-child(odd)      { background-color:#ffffff; } /*Color = White            */
tr:nth-child(even)  { background-color:#004977; color:#ffffff; } /*Color = Specific Blue */
tr:hover            { background-color:#d03027; } /*Color = Specific Red  */

找出問題。

該網頁已被緩存。 我清除了瀏覽器的歷史記錄,並進行了更改。 (使用Ctrl + Shift + R重新加載頁面也將允許進行新的更改)。

將其發布為答案,以防遇到任何相同問題的人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM