这里我要完成的是LI里面套背景图片和右箭图片,由于背景在body里的定义被替换了,只能在LI下套span,又不能用float:right变成浮动的块。只能用li套span,在后面跟上下两个span实现文字的大小标题。这里上代码:
if (count == 0)
{
sb.Append("<li style=\"background:url(http://j5.dfcfw.com/image/201510/20151014113744.png" + ") no-repeat 0px " + -5 + "px;padding-left:0 px; text-align:left;padding:0px 0px 0px 60px;\"><span class=\"combinedImage\"><a href=\"" + "DataCenterSubClass.aspx" + "?type=4&tid=" + tid + "&title=" + title + "\">" + "<span class=\"combinedTextUp\">" + title + "</span>" + "<span class=\"combinedTextDown\">" + description + "</span>" + "</a></span></li>");
}
else
{
sb.Append("<li style=\"background:url(http://j5.dfcfw.com/image/201510/20151014113744.png" + ") no-repeat 0px " + (count - 1) * -39.2 + "px;padding-left:0 px;text-align:left;padding:0px 0px 0px 60px; \"><span class=\"combinedImage\" ><a href=\"" + "DataCenterSubClass.aspx" + "?type=4&tid=" + tid + "&title=" + title + "\">" + "<span class=\"combinedTextUp\">" + title + "</span>" + "<span class=\"combinedTextDown\">" + description + "</span>" + "</a></span></li>");
}
这里combinedImage套在a超级链接的外面,这里上combinedImage的样式:
.combinedImage {
background: url(http://j5.dfcfw.com/image/201412/20141217161819.png) no-repeat right 3px transparent;
z-index:9999;
display:block;
}
这里只能让她右对齐和居右3像素,如果加了float:right就转成块级元素乱掉了。
这里关键是padding,原来是定义上下内边距一个数值 ,左右内边距一个数字,就成padding:0px 60px,这样自然左右都订住,所以右边的箭头始终无法右对齐,问题解决,感谢网上论坛的朋友,虽然问题不一样但是给了很多启发。