【发布时间】:2011-11-04 11:15:44
【问题描述】:
是的,另一个 IE 后备问题。 ;-) 我在 SO 看过其他人,其中大多数都不是多个背景。
IE=9 支持。对于这两者,我完全没问题,甚至没有让它们“多个”,而是让它们简单地平铺图像以供后备。
这是我现有的 CSS:
.main_accent {
background-image: url('../img/background.png');
background-repeat: repeat;
background-image: url('../img/fringe.png'), -webkit-radial-gradient(center, ellipse farthest-corner, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.9)), url('../img/background.png');
background-image: url('../img/fringe.png'), -moz-radial-gradient(center, ellipse farthest-corner, rgba(0, 0, 0, 0), rgba(0,0,0,0.9)), url('../img/background.png');
background-position: bottom, center, center;
background-repeat: repeat-x, no-repeat, repeat;
padding-bottom: 40px;
}
第一个背景图像和重复声明适用于旧版浏览器。然后是 Webkit 和 Mozilla 的多背景图像声明。这些工作正常,以及它们的伴随位置和重复。
“图像”需要按此顺序排列,因为首先填充瓷砖,然后覆盖渐变,然后底部“边缘”(类似于我们都见过的粉红色剪刀效果)完成底部。
问题在于,IE9 或更高版本支持多个背景,但供应商前缀当然会被忽略。这使得 IE9+ 使用普通的非多“背景”规则,但使用第一个位置和重复选项(底部,repeat-x)。我尝试了 3 次简单地使用相同图像的另一个背景图像,但这并不好。
有什么想法吗?
[更新:] 使用速记,但仍然没有运气。 IE 无论如何都想在底部使用那个 repeat-x:
.main_accent {
background: url('../img/background.png') repeat;
background: url('../img/fringe.png') repeat-x bottom, -webkit-radial-gradient(center, ellipse farthest-corner, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.9)) no-repeat center, url('../img/background.png') repeat center;
background: url('../img/fringe.png') repeat-x bottom, -moz-radial-gradient(center, ellipse farthest-corner, rgba(0, 0, 0, 0), rgba(0,0,0,0.9)) no-repeat center, url('../img/background.png') repeat center;
padding-bottom: 40px;
}
【问题讨论】:
-
为什么不使用 CSS 渐变作为背景?较旧的 IE 将通过其专有财产支持这一点。
-
我不知道 IE 有一个专有的 CSS 背景渐变声明,可以在多种背景下工作。
-
看起来很有趣,亚历克斯!但是,这不是代替背景图像吗?我仍然希望显示我的平铺图像。如果我必须在简单的渐变填充或平铺背景之间进行选择,我会选择后者。
-
你可以让它们都运行,但是 CSS 变得有点臃肿。
标签: css