[英]PHP: while() newest bigger font-size
目前,我正在显示我的状态消息:
<?php
while($showSe = mysql_fetch_array($stringUSS)) { ?>
<strong style="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 } ?>
现在,它按ID显示数据库顺序中的所有内容。 我现在想做的是第一个/最新的字体应该具有font-size:18px; 其余的为12px;
您可以使用计数器或标志来指示第一次迭代:
$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++;
}
另一种方法是使用纯CSS:将您的项目放在列表中(例如OL
),然后使用ol > li:first-child > strong
选择第一个LI
的STRONG
元素:
ol > li > strong {
font-size: 12px;
}
ol > li:first-child > strong {
font-size: 18px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.