【问题标题】:Background Image rendering issues in rails 4.1rails 4.1 中的背景图像渲染问题
【发布时间】:2015-02-24 03:41:06
【问题描述】:

我无法理解如何解决我的浏览器(谷歌浏览器和 safari)忽略背景图片的原因。我可以在开发工具中看到正确构建的 url,但是它被删除了(重要的覆盖在这里也仍然失败)。这是我的代码:

body {
  background-image: image-url('blue.jpg') no-repeat center center fixed 
}

图像存储在 app/assets/images 中。

与往常一样,非常感谢任何帮助。

【问题讨论】:

    标签: css ruby-on-rails sass


    【解决方案1】:

    尝试删除 image-url 并仅使用 url

    body {
     background-image: url('blue.jpg') no-repeat center center fixed 
    }
    

    【讨论】:

      【解决方案2】:

      我最终将图像设置为背景而不是背景图像:

      body {
        background: asset_url('blue.jpg') no-repeat center center fixed;
        color: ...
        margin: ...
        padding: ...
      }
      

      我不明白为什么会这样。

      【讨论】:

        猜你喜欢
        • 2011-06-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-26
        • 1970-01-01
        • 2021-11-15
        • 2015-06-06
        相关资源
        最近更新 更多