Bottle中對內聯CSS中的background-image屬性圖片相對路徑url()載入失敗的折中方案

來源:互聯網
上載者:User

Bootle對於靜態檔案的載入是通過路由(@route)和static_file函數來實現的,例如:

1
2
3
@bottle.route( '/imgages/common/<filename:path>')
def imagescommonpath(filename):
     return bottle.static_file(filename, root =  '/admin/imgages/common')
但對於嵌套在CSS中的URL,比如:


卻是通常載入失敗,CSS裡面涉及的url全部失效,即使設定了上面的靜態路由載入這些靜態檔案也同樣失效,目前我沒有找到這種針對CSS裡面的絕對路徑設定問題在Bottle裡面的好的解決方案,既然是絕對路徑的問題導致的失敗,那麼只有更改絕對路徑了,一種折中的方案就是將URL裡面用到的這些jpg, png,gif等檔案同CSS放到同一個檔案夾下,載入的時候,如上面的,進行如下就可以:


各位如有更好的解決方案,敬請告知,多謝。。






相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.