【问题标题】:Can't make path right in css on django site无法在 django 网站上的 css 中正确设置路径
【发布时间】:2021-09-21 18:01:45
【问题描述】:

我在 django 工作,我有一个页面,我在 html 文件中输入了 css,从那里我需要调用背景图像(老实说,有一段时间没有使用 css)。但是我让路径不起作用,甚至将照片与 html 文件放在同一个文件夹中,创建新的,什么都没有。我想把它放在Django_site/static/images/1.jpg。目前我在 Django 文件夹Django_site/Django_app/templates/Django_app/my.html。 你有什么建议?

.bgimg {
  background-image: url('images/1.jpg');
  height: 100%;
  background-position: center;

【问题讨论】:

    标签: css django


    【解决方案1】:
     background-image: url("{% static 'images/1.jpg' %}")
    

    【讨论】:

      【解决方案2】:
      You can move any CSS that contains static file paths to inline CSS, contained in the template.
      

      please visit in this link

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多