CSS3背景-多个背景尺寸属性 [英] CSS3 Backgrounds - multiple background-size properties

查看:125
本文介绍了CSS3背景-多个背景尺寸属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一些可能不可能的事情,但让我们看看您的想法.这是我的代码:

I'm trying to do something maybe impossible, but lets see what do you think. Here is my code:

html {
    background: url(../img/pattern.png) repeat, url(../img/up2.jpg) no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-color: black; 
}

因此,我试图获取具有多个背景的html元素,例如2,问题是我只想将background-size设置为第二个背景,而不是第一个背景.有什么想法吗?

So im trying to get the html element with multiple backgrounds for example 2 and the problem is that i want to set background-size only to the second background and not for the first one.. Any ideas?

推荐答案

您需要重置第一个图像的大小,然后为第二个图像指定大小. 规范说,background-size的初始值为auto,表示:

You need to reset the size for the first image, then specify it for the second. The spec says that the initial value of background-size is auto, which means:

-webkit-background-size: auto, cover;
-moz-background-size: auto, cover;
-o-background-size: auto, cover;
background-size: auto, cover;

这篇关于CSS3背景-多个背景尺寸属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆