2014-02-11 77 views
2
  • 固定背景单个图像?
  • 固定背景,单幅图像,缩放和居中?
  • 两个背景,每边50%?
  • 三种背景,每种33%,封面样式缩放,同时也是100%的高度?

我需要背景图像,每个占用布局像这样屏幕的33%:多CSS背景设置为覆盖50%100%大小(并修复!)

11111|22222|33333 
11111|22222|33333 
11111|22222|33333 
11111|22222|33333 
11111|22222|33333 

此背景需要被固定的,因为其他的东西在上边滑动的。我已经成功地还挺得到这个工作有两个背景图像有以下:

.multiple-background { 
    background-color: transparent; 
    background-image: url("img1.jpg"), url("img2.jpg"); 
    background-repeat: no-repeat, no-repeat; 
    background-attachment: fixed, fixed; 
    background-clip: border-box, border-box; 
    background-origin: padding-box, padding-box; 
    background-size: 50% 100%; 
    background-position: left top, right top; 
} 

可惜这绵延的背景图像。我需要的东西可以让我修复图像占用的水平空间量(33%),同时还可以实现100%的宽度和覆盖样式缩放。

切换像background-size: 50% auto;这样的东西可以正确缩放,但现在它不覆盖整个背景。

+0

我不认为你可以做到这一点'背景size'设置位置绝对和z-index值。 'contains','cover'和'auto' * all *仅根据其固有比例缩放图像。 – BoltClock

+0

注意,如果某个背景属性对于所有背景都具有相同的值,则可以只指定一次,并将其传播到其余背景。这意味着'background-attachment:fixed'相当于'background-attachment:fixed,fixed',例如'background-clip','background-origin'和'background-repeat'也是如此。 – BoltClock

+0

@BoltClock我从FF的检查器中复制了这个,所以这就是扩展的CSS。好的提示,但! –

回答

0

每个背景使用differenet元素和订货