html - 如何保持图像背景图像静止?

标签 html css background background-image

我想将一个图像固定为背景,同时在其上滚动一个半透明框。然而,当我尝试在 4:3 比例的屏幕上执行此操作时,图像只是切成两半。

这是我的 CSS:

.content {
    background-color: black;
    background-image:url('http://xurbia.tk/alpha/pictures/Croped%20Xurbiar%20Logo%20Mr.%20Isolation.png');
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
    background-position: center;        
}

这是我想做的一个例子:

http://s.codepen.io/shardros/debug/vOVWwp

任何帮助将不胜感激。

最佳答案

body 标签而不是 .content 上设置背景,这样就可以了。

body {
    background-color: black;
    background-image:url('http://xurbia.tk/alpha/pictures/Croped%20Xurbiar%20Logo%20Mr.%20Isolation.png');
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
    background-position: center;        
}

Updated Example

关于html - 如何保持图像背景图像静止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31636920/

相关文章:

php - 忽略提示,使用表格或 div?

javascript - 输入文件 - 如果未更改,请保留以前的文件

javascript - 使用javascript在div上切换多个css类

jquery - setinterval() 和clearinterval() - 清除后,不会自动设置动画

swift Realm 在后台线程中然后应用程序崩溃

javascript - div 与背景图像大小相同

javascript - 究竟如何进行这个循环的进步呢? (兼容Internet Explorer 9,时间准确)

android - 如何制作一个带倒圆角的矩形?

jquery - CSS:在bootstrap modalWindow中隐藏一个滚动条

javascript - 拇指前的样式输入范围背景