Use Django template syntax in a css file

后端 未结 3 429
旧巷少年郎
旧巷少年郎 2020-12-19 05:28

I have a css file home_global.css which has the following in it:

body {
    background-image: url(\"{% static \'citator/citator.jpg\' %}\");
}
         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-19 05:40

    Chopped off the particular part of the CSS tag and add into HTML file using style tag. A quick fix and worked for me.

    main.css

      ...
    
    #banner {
        background-color: #e5474b;
        color: #f2a3a5;
        padding: 13em 0 11em 0;
        background-color: #0c0c0c;
        background-image: url("/images/banner.jpg"); <-- Remove this part and put under html
        background-size: cover;
        background-repeat: no-repeat;
        background-position: 15% left;
        text-align: right;
        position: relative;
        z-index: 9999;
    }
      ...
    

    index.html

    
      ...
      
     ...
    
    

提交回复
热议问题