How to refer to static files in my css files?

后端 未结 8 1815
醉话见心
醉话见心 2020-12-24 11:19

I have a reference inside my CSS file that refers to a static image:

#logo
{
  background: url(\'/static/logo.png\')
}

This works just fi

8条回答
  •  臣服心动
    2020-12-24 11:36

    If you're using django-libsass to generate your css, you can use custom functions to bridge django and the sass precompiler.

    As a matter of fact, the function static is already implemented, and you can use it:

    .foo {
        background: url(static("myapp/image/bar.png"));
    }
    

    as described here: https://github.com/torchbox/django-libsass#custom-functions

提交回复
热议问题