适用于iOS的多个固定和拉伸背景

时间:2016-10-03 12:54:08

标签: html ios css

我正在尝试创建一个在某些div上具有多个固定和拉伸背景的网站。 超级简单,只需使用:

background-image:url(../some-image.jpg);
background-position: center center;
background-attachment: fixed;
background-size: cover;

在每个需要背景的div上但由于某种原因,在iOS上,背景不是固定的,也没有拉伸到正确的大小。

我在此处找到了此修复程序:https://css-tricks.com/forums/topic/full-page-backgrounds-on-ios-background-size-cover/page/3/

.bg {
    background: url(image.jpg);
    background-size: cover;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    height: 100%;
    width: 100%;
    position: fixed;
    background-position: center center;
    background-repeat: no-repeat;
}

基本上他将尺寸和固定属性直接赋予div而不是背景。 我的问题是,如果你只需要1个背景,但我无法弄清楚如何在不同的背景上使用不同的背景来解决这个问题。

0 个答案:

没有答案