开发者

PHP: while() newest bigger font-size

Currently im having this for displaying my statusmessages:

<?php
while($showSe = mysql_fetch_array($stringUSS)) { ?>

    <strong s开发者_运维技巧tyle="font-size: 12px;"><?php get_day_name($showSe["date"]); get_time($showSe["date"]); ?>  </strong><br>
    <span style="font-size: 20px; text-align: center; margin: 10px;"><?php echo $showSe["status"]; ?></span>
    <hr>
<?php } ?>

Now it displays everything from the database order by id. What i want to do now is that the first/newest one, should have font-size: 18px; while the rest have 12px;


You could use a counter or a flag to indicate the first iteration:

$counter = 0;
while ($showSe = mysql_fetch_array($stringUSS)) {
    $fontSize = ($counter === 0) ? 18 : 12;
?>
<strong style="font-size: <?php echo $fontSize;?>px;"><?php get_day_name($showSe["date"]); get_time($showSe["date"]); ?>  </strong><br>
<span style="font-size: 20px; text-align: center; margin: 10px;"><?php echo $showSe["status"]; ?></span>
<?php
    $counter++;
}

Another way would be to use pure CSS: Put your items in a list (e.g. OL) and use ol > li:first-child > strong to select the STRONG element of the first LI:

ol > li > strong {
    font-size: 12px;
}
ol > li:first-child > strong {
    font-size: 18px;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜