新闻标题 和 发布时间 不在同一行显示 怎么办?

early_1 2011-03-22 02:52:02
前台新闻显示代码:

<div c<div class="TB_content">

<%Call Ok3w_Article_List(27,6,1,17,False,False,true,2,False,"")%>

</div>
-------------------------
(其中TB_content的CSS为:

.TB_content{width:340px; height:190px; float:right; font-size:12px; line-height:20px; padding-top:10px; padding-bottom:8px; text-align:left;}



==============================================================================================================

后台Ok3w_Article_List函数为:

Private Sub Ok3w_Article_List(ClassID,Rows,Cels,LeftN,IsCommend,DisClass,DisTime,TimeFormat,DisHits,OrderType)
Sql="select top " & Rows * Cels & " Id,Title,TitleColor,TitleURL,AddTime,Hits from Ok3w_Article where ChannelID=1 and IsPass=1 and IsDelete=0"
If ClassID<>"" Then Sql=Sql & " and SortPath like '%," & ClassID & ",%'"
If IsCommend Then Sql=Sql & " and IsCommend=1"
Select Case OrderType
Case "hot"
Sql = Sql & " order by Hits desc,AddTime desc,ID desc"
Case "rnd"
Randomize
Sql = Sql & " order by Rnd(-(ID+"&Rnd()&")),ID desc"
Case "new"
Sql = Sql & " order by AddTime desc,ID desc"
Case Else
Sql = Sql & " order by IsTop desc,IsCommend desc,AddTime desc,ID desc"
End Select
Rs.Open Sql,Conn,0,1
StrTmp = "<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"">"
Do While Not Rs.Eof
StrTmp = StrTmp & "<tr>"
For II=1 To Cels
If Rs.Eof Then
StrTmp = StrTmp & "<td> </td>"
Else
StrTmp = StrTmp & "<td class=""newstitle""><div>"
If DisClass Then
StrTmp = StrTmp & "[<a href=""" & Htmldns & """list.asp?id=" & Rs("ClassID") & """>" & GetClassName(Rs("ClassID")) & "</a>]"
Else
StrTmp = StrTmp & "·"
End If
StrTmp = StrTmp & Format_TitleURL("show.asp",Rs("ID"),Rs("Title"),Rs("TitleColor"),Rs("TitleURL"),LeftN)
StrTmp = StrTmp & "</div><span>"
If DisHits Then
StrTmp = StrTmp & " 查看:" & Rs("Hits")
End If
If DisTime Then
StrTmp = StrTmp & " " & Format_Time(Rs("AddTime"),TimeFormat)
End If
StrTmp = StrTmp & "</span>"
StrTmp = StrTmp & "</td>"
Rs.MoveNext
End If
If Cels<>1 And II<>Cels Then
StrTmp = StrTmp & "<td> </td>"
End If
Next
StrTmp = StrTmp & "</tr>"
Loop
Rs.Close
StrTmp = StrTmp & "</table>"
Response.Write(StrTmp)
End Sub
...全文
342 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
qqm05 2011-03-22
  • 打赏
  • 举报
回复
因为<div> 是一个块级元素,也就是说,浏览器通常会在 div 元素前后放置一个换行符。
所以要设置div为浮动的,其次表格的列宽和div的宽度也要同时设好,不然浏览器咋知道你要多宽呢?
要设置间隙的话,可以在他们中间加个固定宽度的浮动的div,或者直接设置标题div的样式margin-right或者padding-right
Horrison 2011-03-22
  • 打赏
  • 举报
回复

//加这句
style="nowrap="nowrap";"
early_1 2011-03-22
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 qqm05 的回复:]

.newstitle {width:400px;}
.newstitle div {float:left; width:150px;}
这样呢?
[/Quote]

可以了,谢谢你。

现在是在同一行显示了,但 新闻标题 和 发布时间 紧挨着,我想把发布时间 靠后,该怎么改?还有,为什么这么写就行了呢,原来的怎么不行?
qqm05 2011-03-22
  • 打赏
  • 举报
回复
.newstitle {width:400px;}
.newstitle div {float:left; width:150px;}
这样呢?
early_1 2011-03-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 qqm05 的回复:]
把标题所在的div设置为浮动,宽度设为你想要的宽度:
.newstitle div {float:left; width:150px;}
[/Quote]

谢谢回答 可是还是不行!
qqm05 2011-03-22
  • 打赏
  • 举报
回复
把标题所在的div设置为浮动,宽度设为你想要的宽度:
.newstitle div {float:left; width:150px;}
early_1 2011-03-22
  • 打赏
  • 举报
回复
显示为:新闻标题
时间

我想正确显示为: 新闻标题 时间

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧