可能重复:
CSS3 选择器最后一个不属于 X 类的元素
我有这个循环:
for($t=0; $t<$numRowszzx; $t++)
{
if(!isset($_GET["prodcat"]))
{
header("Location: products.php?prodcat=".$rowzx[0]["category_id"]);
}
$categoryName = $rowzx[$t]["category_name"];
if($rowzx[$t]["category_id"]==$_GET["prodcat"])
{
?>
<li style="height:30px; line-height:30px; color:#2a598a; font-weight:bold; font-size:14px;"><img src="<?=$site_url?>/images/parrows.png" width="13" height="7" /><span style="padding-left:12px;"><a href="<?=$site_url?>/products.php?prodcat=<?=$rowzx[$t]["category_id"];?>" style=" color:#f15a22; font-weight:bold; font-size:14px;"><?=$categoryName?></a></span></li>
<?php
} else {
?>
<li style="<?php if($i > $numRowszzx-1){ ?>margin-bottom:500px;<?php } ?> height:30px;line-height:30px; color:#2a598a; font-weight:bold; font-size:14px;"><img src="<?=$site_url?>/images/parrows.png" width="13" height="7" /><span style="padding-left:12px;"><a href="<?=$site_url?>/products.php?prodcat=<?=$rowzx[$t]["category_id"];?>" style=" color:#2a598a; font-weight:bold; font-size:14px;"><?=$categoryName?></a></span></li>
<?php
}
}
现在我需要得到最后一个li ...在这段代码中,如果li是最后一个,我需要做,给它margin-bottom:500px;
else {
?>
<li style="<?php if($i > $numRowszzx-1){ ?>margin-bottom:500px;<?php } ?> height:30px;line-height:30px; color:#2a598a; font-weight:bold; font-size:14px;"><img src="<?=$site_url?>/images/parrows.png" width="13" height="7" /><span style="padding-left:12px;"><a href="<?=$site_url?>/products.php?prodcat=<?=$rowzx[$t]["category_id"];?>" style=" color:#2a598a; font-weight:bold; font-size:14px;"><?=$categoryName?></a></span></li>
<?php
}
请问有什么帮助吗?