如果使用得少CSS,你可以做到以下幾點:
/**
* Defines a horizontal gradient, but allows additional image url's to be passed through the CSS3 compliant browsers to display multiple i
* image on the one element
*/
.background-gradient-multiple(@start-color, @end-color) {
.background-gradient-horizontal(@start-color, @end-color);
}
.background-gradient-multiple(@start-color, @end-color, @additional-background) {
.background-gradient-horizontal(@start-color, @end-color, @additional-background ~ ',');
}
.background-gradient-horizontal(@start-color, @end-color, @additional-background: ~'') {
background-color: @start-color;
background-image: @additional-background -moz-linear-gradient(left, @start-color, @end-color);
background-image: @additional-background -webkit-gradient(linear, 0 0, 100% 0, from(@start-color), to(@end-color));
background-image: @additional-background -webkit-linear-gradient(left, @start-color, @end-color);
background-image: @additional-background -o-linear-gradient(left, @start-color, @end-color);
background-image: @additional-background linear-gradient(to right, @start-color, @end-color);
filter: progid:DXImageTransform.Microsoft.gradient([email protected], [email protected], GradientType=0);
}
在一個類來執行這一點,你可以這樣做:
.class { .background-gradient-multiple(#000000, #FFFFFF, 'url(images/test.gif) no-repeat top left'); }
你的元素有多大?他們有固定的大小嗎? – knut
我真的不知道在哪裏回答你們所有人,因爲看起來我不允許「在我的消息中添加答案」:)顯然,在不同的CSS語句中使用多個背景功能是沒有辦法的,所以我會暫時忘記漸變。謝謝你們。哦,我也把所有的CSS放在不同的CSS文件中,與HTML不同,我的意思是Shauna說。 –
好吧,現在我得到了爲什麼我不能發佈一個答案,這不是一個答案:) –