在调整大小时停止移动背景的CSS背景属性

时间:2013-01-21 08:14:20

标签: html css properties background

我最近在最近的一个问题上发现了这个问题,这个问题与我认为是Chrome或Safari webkit bug有关,或者也许是我的style.css中的内容。但是,我注意到一段时间后我的背景稍微调整大小,我得出结论,当它向右移动时,左边的白色边框在屏幕左侧从上到下没有出现,但是当背景图片向右侧移动,然后左侧出现2px白色边框。如何阻止边界移动。

我的CSS:

html { 
    background: url(/assets/fotball.jpg) no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover; 
}

2 个答案:

答案 0 :(得分:0)

试试这个:

background: url(/assets/fotball.jpg) no-repeat center top fixed; 

答案 1 :(得分:0)

将您的代码更改为:jsFiddle Live Demo

html { 
    background: url(/assets/fotball.jpg) repeat center top fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-position:;
}

使用background-size: cover;时,使用background:no-repeatbackground:repeat没有任何区别。因此,在这种情况下,您可以使用repeat来解决您的问题。