我是一個iPhone應用程序開發者和有關於css.I非常瞭解甚少有一個代碼來創建一個沒有cells.here這就是:CSS代碼定製
<style type="text/css" media="screen">
body {
margin: 0;
width: 320px;
height: 200px;
}
.ad-carousel-view .cells > li {
width: 200px;
height: 70px;
padding-top: 16px;
padding-left: 20px;
color: white;
font-size: 20px;
font-family: "Helvetica Neue", Helvetica;
-webkit-border-radius: 10px;
-webkit-box-sizing: border-box;
background-image:url('13.jpg');
}
.ad-carousel-view .cells > li:nth-child(odd) {
background-color: rgb(255,59,59);
}
.ad-carousel-view .cells > li:nth-child(even) {
background-color: rgb(80,80,80);
background-image:url('13.jpg');
}
.ad-carousel-view .cells > li.active {
background-color: red;
background-image:url('23.jpg');
}
</style>
<style type="text/css">
.wrap{
border:solid 1px #000000;
width:320px;
height:150px;
position:relative;
top:0px;
left:0px;
}
</style>
在上面
下面的一段代碼被用於設置單元格的背景色和圖像
//odd cell
.ad-carousel-view .cells > li:nth-child(odd) {
background-color: rgb(255,59,59);
}
//even cell
.ad-carousel-view .cells > li:nth-child(even) {
background-color: rgb(80,80,80);
background-image:url('13.jpg');
}
//highlighted cell
.ad-carousel-view .cells > li.active {
background-color: red;
background-image:url('23.jpg');
}
現在我需要的是動態改變背景圖片...我的意思,而不是使用
background-image:url('23.jpg');
我想用變量類似
background-image:url(var);
是否有可能在CSS?....如果沒有那麼任何人都可以有任何想法,以動態地設置圖像的名字?
我認爲你的權利..... – Rony 2010-07-20 13:10:04
你可以給我更多的細節...我試圖使用的代碼..在負載上的HTML身體我稱之爲功能..setImage.like..but沒有任何反應.. function setImage() \t { \t \t alert(「Hello ..」); \t $('。ad-carousel-view .cells> li.active')。each(function(){ \t \t alert(「Hello ..「); VAR IMG = getYourImagePath(); $(本)的.css({背景圖片:IMG}); });定義 \t \t } – Rony 2010-07-21 05:22:33
你有一個叫getYourImagePath(功能)這就是你將需要把返回背景圖像路徑的邏輯 – Pat 2010-07-21 10:27:49