【问题标题】:In Rails / bootstrap, why isn't the background image stretching properly?在 Rails / bootstrap 中,为什么背景图像不能正确拉伸?
【发布时间】:2013-10-13 17:24:29
【问题描述】:

我正在使用引导程序和导轨。我试图让背景图像占据整个背景并在浏览器较大时拉伸。这在大多数情况下都有效,除了当浏览器较小时,图像的底部会上升并且浏览器屏幕的底部是空白的。这是我现在拥有的 css:

body { 
  background-image: url('bilde.jpg');
  background-repeat: no-repeat;
  background-position: fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

我试过这个:

body {
  background-image: url('bilde.jpg') no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

但它也不起作用。有人有这个问题的答案吗?谢谢。

【问题讨论】:

  • 你有显示这种行为的链接吗?
  • 我在本地运行它,但这里有一个 jsfiddle:jsfiddle.net/QGJv6

标签: css ruby-on-rails twitter-bootstrap background-image background-position


【解决方案1】:

我想通了。不同的是我应该一直在使用

background: url('bilde.jpg') no-repeat center center fixed;

而不是

background-image: url('bilde.jpg') no-repeat center center fixed;

相当微妙,但改变成功了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-25
    • 1970-01-01
    • 2012-09-19
    • 2010-11-09
    • 2011-11-12
    • 1970-01-01
    • 1970-01-01
    • 2017-01-18
    相关资源
    最近更新 更多