在编写新闻列表的时候,一般要求左边是新闻标题,右边是新闻发布时间。时间一般会放在<span>标签中,并将其右浮动。
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.51texiao.cn/" />
<title>蚂蚁部落</title>
<style type="text/css">
li{
list-style-type:none;
font-size:12px;
color:blue;
width:300px;
height:30px;
line-height:30px;
border-bottom:1px dashed blue;
}
span{
color:red;
width:60px;
height:30px;
float:right;
}
</style>
</head>
<body>
<div>
<ul>
<li><a href="#">蚂蚁部落欢迎您</a><span>2012-12-13</span></li>
<li><a href="#">大家好,好久不见了</a><span>2012-12-13</span></li>
<li><a href="#">蚂蚁部落</a><span>2012-12-13</span></li>
</ul>
</div>
</body>
</html>
以上代码在IE8或者FF浏览器中是正常的,但是在IE6浏览器中时间却换行了。
解决方案:将<a>标签和<span>标签分别浮动起来,分别左右浮动即可。代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.51texiao.cn/" />
<title>蚂蚁部落</title>
<style type="text/css">
li{
list-style-type:none;
font-size:12px;
color:blue;
width:300px;
height:30px;
line-height:30px;
border-bottom:1px dashed blue;
}
a{
width:240px;
height:30px;
float:left;
}
span{
color:red;
width:60px;
height:30px;
float:right;
}
</style>
</head>
<body>
<div>
<ul>
<li><a href="#">蚂蚁部落欢迎您</a><span>2012-12-13</span></li>
<li><a href="#">大家好,好久不见了</a><span>2012-12-13</span></li>
<li><a href="#">蚂蚁部落</a><span>2012-12-13</span></li>
</ul>
</div>
</body>
</html>
第二种解决方法:
例如原先:
[loop={@num}]
<li><a href="{@linkurl}"target="_blank">{@title}...</a><span class="liebiaoyou">{@adddate}</span></li>
[/loop]
把他反过来写就可以解决了
[loop={@num}]
<li> <span class="liebiaoyou">{@adddate}</span> <a href="{@linkurl}"target="_blank">{@title}...</a></li>
[/loop]