最近公司做的一个网站制作案例的有一块的要求是,新闻无缝滚动,同一行前面是新闻标题,后面是新闻发布日期,所有日期格式要对齐,这里不讨论JS怎么去实现,只说说其中的CSS部分:
#upnews {padding-left:2px;text-align:left;} #upnews ul {margin:0; padding:0;height:150px;overflow:hidden;line-height:25px; } #upnews ol {margin:0;} #upnews ol li {list-style:decimal outside;line-height:25px;} 既然要同行而且要日期格式对齐,肯定把标题与日期要横排,标题一个宽度,日期一个宽度,直接下面的CSS代码:
#upnews ol li .title{line-height:25px;width:248px;float:left;} #upnews ol li .addtime{line-height:25px;width:60px;float:left;font-size:10px;color:#FF6600} 这样行吗?结果是日期与标题换行了,作下改动把title和addtime写到新闻的CSS里: #indexnews .tzgg .sing .title{line-height:25px;width:248px;float:left;} #indexnews .tzgg .sing .addtime{line-height:25px;width:60px;float:left;font-size:10px;color:#FF6600} 同时把写在li里的title和addtime去掉,结合PHP代码如下:
<div id="upnews"> <ul> <?php $sql_notices2="SELECT * FROM `eobo_cn_news` WHERE `cate`='$cate' ORDER by id DESC LIMIT 20"; $query_notices2=$db->query($sql_notices2); while($row_notices2=$db->fetch_array($query_notices2)) { ?> <li><div class="sing"><div class="title"><img src="images/dot.gif" alt="<?php echo $row_notices2["title"];?>" width="13" height="10" /><a href="readnotices.php?
newsid=<?php echo $row_notices2["id"]?>" class="blues" title="<?php echo $row_notices2["title"];?>"><?php echo GBsubstr($row_notices2["title"],0,50);?></a></div><div
class="tm">[<?php echo $row_notices2["addtime"]; ?>]</div></div></li> <?php }?> </ul> </div>
本文地址:http://www.eobo.cn/news/418.html
|