1

我的问题是:如何让我的 2 个背景图像出现在 CSS 渐变上方的左右两侧。我正在使用 JA Elastica 模板(修改默认 CSS)在 Joomla 网站上工作。

在我当前的CSS中,如果我将“背景:url('images')”放在渐变上方,那么它会显示图像而不是渐变,如果我将它放在渐变下方,它会显示渐变而不是图像。

我目前使用的代码是这样的:

body#bd {
background-image: linear-gradient(bottom, rgb(142,210,46) 2%, rgb(171,252,74) 51%, rgb(206,255,104) 76%);
background-image: -o-linear-gradient(bottom, rgb(142,210,46) 2%, rgb(171,252,74) 51%, rgb(206,255,104) 76%);
background-image: -moz-linear-gradient(bottom, rgb(142,210,46) 2%, rgb(171,252,74) 51%, rgb(206,255,104) 76%);
background-image: -webkit-linear-gradient(bottom, rgb(142,210,46) 2%, rgb(171,252,74) 51%, rgb(206,255,104) 76%);
background-image: -ms-linear-gradient(bottom, rgb(142,210,46) 2%, rgb(171,252,74) 51%, rgb(206,255,104) 76%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.02, rgb(142,210,46)),
color-stop(0.51, rgb(171,252,74)),
color-stop(0.76, rgb(206,255,104)));
background:
url('https://dl.dropbox.com/u/6512758/onebeat.ro/right.png') no-repeat top right,
url('https://dl.dropbox.com/u/6512758/onebeat.ro/left.png') no-repeat top left;
}
4

1 回答 1

2

一切都需要在同一个背景图像属性上,否则前一个背景语句将被下一个替换。例如:

background-image: url('https://dl.dropbox.com/u/6512758/onebeat.ro/right.png') no-repeat top right, linear-gradient(bottom, rgb(142,210,46) 2%, rgb(171,252,74) 51%, rgb(206,255,104) 76%);

在这里查看更多示例: 如何在同一元素上组合背景图像和 CSS3 渐变?

于 2012-10-01T14:42:35.107 回答