CSS3 背景 - 多个背景大小属性

标签 css

我正在尝试做一些可能不可能的事情,但让我们看看你怎么想。这是我的代码:

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,问题是我只想将背景大小设置为第二个背景,而不是第一个背景。有什么想法吗?

最佳答案

您需要重置第一个图像的尺寸,然后为第二个图像指定尺寸。 spec表示background-size的初始值为auto,这意味着:

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

关于CSS3 背景 - 多个背景大小属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16919890/

相关文章:

css - 如何垂直对齐 float 图像旁边的文本?

html - Jenkins 内容安全策略

html - 固定菜单左对齐

php - 需要在div出现在页面之前getElementById

jquery - 用 animate() CSS3 替换 jQuery 幻灯片

java - 为 GWT css 类启用混淆吗?

html - 如何在动态创建的 TR 元素上放置背景颜色

css - Bootstrap 进度条文本不居中

java - 从相机 Intent 中获取位图图像作为缩略图。如何让它变大

javascript - 设置重置按钮以清除文本类型的特定单个输入