Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[已解决] 哪位老大帮忙帮看看这段代码?强制标题字节!标题太长标题太长标题太长标题太长...12

[复制链接]
站站鱼 发表于 2010-10-20 16:38:56 | 显示全部楼层 |阅读模式
本帖最后由 站站鱼 于 2010-10-20 17:25 编辑

这里是论坛列表中,因为开启边栏,所以不希望标题显示过长,并且不希望它换行,希望通过css限制标题长度,超过450px宽度后不显示
通过好多代码也没能实现

  1. /* ------------------------------列表式样forum_show_list_box------------------------------ */
  2. .forum_show_list_box { width:450px; font-weight: 450;float: left; margin-top:4px; margin-bottom:4px; line-height:20px; white-space:nowrap;word-break:keep-all;overflow:hidden;text-overflow:ellipsis;}
  3. .forum_show_list_box a { width:450px; font-weight: 450; text-decoration:none; overflow:hidden;
  4. }
  5. .forum_show_list_box a:link { width:450px; font-weight: 450;color:#464657; text-decoration:none;  overflow:hidden;
  6. }
  7. .forum_show_list_box a:hover { cwidth:450px; font-weight: 450;olor:#FFF; background:#A5D63C;font-weight:bold; overflow:hidden;
  8. }
复制代码

<div class="forum_show_list_box">$thread[subject]</div>这样不行

<dd  style="float:left;width:450px;white-space:nowrap;word-break:keep-all;overflow:hidden;text-overflow:ellipsis;">$thread[subject]</dd>
火狐下起作用,ie、360下都不行
试了N种方式也无法解决?希望路过的朋友给指点迷津!非常感谢



  1. <th>
  2. <div class="forumdisplay_linksbox">
  3. <dl style="float:left;width:450px;white-space:nowrap;word-break:keep-all;overflow:hidden;text-overflow:ellipsis;">

  4. <!--{hook/forumdisplay_thread $key}-->
  5. $thread[sorthtml] $thread[typehtml]
  6. <!--{if $thread['moved']}-->
  7. {lang thread_moved}:<!--{eval $thread[tid]=$thread[closed];}-->
  8. <!--{/if}-->
  9. <!--{if $thread['isgroup'] == 1}-->
  10. <!--{eval $thread[tid]=$thread[closed];}-->
  11. [<a href="forum.php?mod=forumdisplay&action=list&fid={$groupnames[$thread[tid]][fid]}" target="_blank">{$groupnames[$thread[tid]][name]}</a>]
  12. <!--{/if}-->


  13. <a href="forum.php?mod=viewthread&tid=$thread[tid]&{if $_G['gp_archiveid']}archiveid={$_G['gp_archiveid']}&{/if}extra=$extra"$thread[highlight]{if $thread['isgroup'] == 1} target="_blank"{/if} onclick="atarget(this)" class="xst"style="font-size: 16px;font-family:'黑体'">$thread[subject]</a>

  14. <!--{if $thread[icon] >= 0}-->
  15. <img src="{STATICURL}image/stamp/{$_G[cache][stamps][$thread[icon]][url]}" alt="{$_G[cache][stamps][$thread[icon]][text]}" align="absmiddle" />
  16. <!--{/if}-->
  17. <!--{if $stemplate && $sortid}-->$stemplate[$sortid][$thread[tid]]<!--{/if}-->
  18. <!--{if $thread['readperm']}--> - [{lang readperm} <span class="bold">$thread[readperm]</span>]<!--{/if}-->
  19. <!--{if $thread['price'] > 0}-->
  20. <!--{if $thread['special'] == '3'}-->
  21. - <span style="color: #C60">[{lang thread_reward}{$_G[setting][extcredits][$_G['setting']['creditstransextra'][2]][title]} <span class="bold">$thread[price]</span> {$_G[setting][extcredits][$_G['setting']['creditstransextra'][2]][unit]}]</span>
  22. <!--{else}-->
  23. - [{lang price} {$_G[setting][extcredits][$_G['setting']['creditstransextra'][1]][title]} <span class="bold">$thread[price]</span> {$_G[setting][extcredits][$_G['setting']['creditstransextra'][1]][unit]}]
  24. <!--{/if}-->
  25. <!--{elseif $thread['special'] == '3' && $thread['price'] < 0}-->
  26. - [{lang reward_solved}]
  27. <!--{/if}-->
  28. <!--{if $thread['attachment'] == 2}-->
  29. <img src="{STATICURL}image/filetype/image_s.gif" alt="attach_img" title="{lang attach_img}" align="absmiddle" />
  30. <!--{elseif $thread['attachment'] == 1}-->
  31. <img src="{STATICURL}image/filetype/common.gif" alt="attachment" title="{lang attachment}" align="absmiddle" />
  32. <!--{/if}-->
  33. <!--{if $thread['displayorder'] == 0}-->
  34. <!--{if $thread[recommendicon] && $filter != 'recommend'}-->
  35. <img src="{IMGDIR}/recommend_$thread[recommendicon].gif" align="absmiddle" alt="recommend" title="{lang thread_recommend} $thread[recommends]" />
  36. <!--{/if}-->
  37. <!--{if $thread[heatlevel]}-->
  38. <img src="{IMGDIR}/hot_$thread[heatlevel].gif" align="absmiddle" alt="heatlevel" title="$thread[heatlevel] {lang heats}" />
  39. <!--{/if}-->
  40. <!--{if $thread['digest'] > 0 && $filter != 'digest'}-->
  41. <img src="{IMGDIR}/digest_$thread[digest].gif" align="absmiddle" alt="digest" title="{lang thread_digest} $thread[digest]" />
  42. <!--{/if}-->
  43. <!--{if $thread['rate'] > 0}-->
  44. <img src="{IMGDIR}/agree.gif" align="absmiddle" alt="agree" title="{lang rate_credit_add}" />
  45. <!--{elseif $thread['rate'] < 0}-->
  46. <img src="{IMGDIR}/disagree.gif" align="absmiddle" alt="disagree" title="{lang posts_deducted}" />
  47. <!--{/if}-->
  48. <!--{/if}-->

  49. <!--{if $thread['weeknew']}-->

  50. <a href="forum.php?mod=redirect&tid=$thread[tid]&goto=lastpost#lastpost"><img src="{IMGDIR}/icon_new.gif" border="0" title="新内容" /></a>
  51. <!--{/if}-->
  52. </dl>
  53. </div>


  54. <div class="shortmsg_linksbox"style="color: #201E2B">

  55. <!--{if $thread['authorid'] && $thread['author']}-->
  56. <span class="pipe">{lang author}:<a href="home.php?mod=space&uid=$thread[authorid]" c="1">$thread[author]</a><!--{if !empty($verify[$thread['authorid']])}-->$verify[$thread[authorid]]<!--{/if}-->
  57. <!--{else}-->
  58. <!--{if $_G['forum']['ismoderator']}-->
  59. <a href="home.php?mod=space&uid=$thread[authorid]" c="1">{lang anonymous}</a>
  60. <!--{else}-->
  61. {lang anonymous}
  62. <!--{/if}-->
  63. <!--{/if}-->
  64. </span>

  65. <span class="pipe">日期:{eval $days=date('Y-n-j',time());}


  66. <div class="forumdisplay_linksbox">
  67. white-space:nowrap;word-break:keep-all;overflow:hidden;text-overflow:ellipsis;

  68. <dl style="float:left;width:450px;white-space:nowrap;word-break:keep-all;overflow:hidden;text-overflow:ellipsis;">




  69. <!--{if $thread[dateline]==$days}-->
  70. <font color="#0099FF">$thread[dateline]</font>
  71. <!--{else}-->
  72. $thread[dateline]
  73. <!--{/if}--></span>
  74. <span class="pipe">关注:$thread[views]</span>
  75. <span class="pipe">评论:<a href="forum.php?mod=viewthread&tid=$thread[tid]&extra=$extra" class="xi2">$thread[replies]</a></span> </div>
  76. <div class="shortmsg_linksbox"> <em style="color: #888">$thread['message']</em>
  77. <!--{if $thread[multipage]}-->
  78. <span class="tps">$thread[multipage]</span>
  79. <!--{/if}-->
  80. <!--{if $thread['displayorder'] <= 0 }-->
  81. <a href="forum.php?mod=viewthread&tid=$thread[tid]&{if $_G['gp_archiveid']}archiveid={$_G['gp_archiveid']}&{/if}extra=$extra"><b>详细查看</b></a>
  82. <!--{else}-->
  83. <!--{/if}-->
  84. </div> </th>
复制代码

回复

使用道具 举报

cr180 发表于 2010-10-20 21:00:42 | 显示全部楼层
本帖最后由 cr180 于 2010-10-20 21:01 编辑

回复 站站鱼 的帖子

打开文件:source\module\forum\forum_forumdisplay.php

查找:
  1. if($thread['highlight'])
复制代码


上面加:

  1. $thread['subject'] = cutstr($thread['subject'], 10, $dot = ' ...');
复制代码



这段代码里面10的数字是截取字符长度为10字节(5个汉字),超出的则显示...,自己调整一下吧 ,css调整涉及很多的问题

评分

1

查看全部评分

回复

使用道具 举报

 楼主| 站站鱼 发表于 2010-10-20 17:06:04 | 显示全部楼层
继续关注....
回复

使用道具 举报

zetime 发表于 2010-10-20 18:06:57 | 显示全部楼层
不是很懂不过帮你顶一下

评分

1

查看全部评分

回复

使用道具 举报

 楼主| 站站鱼 发表于 2010-10-20 19:47:49 | 显示全部楼层
实在不理解?
回复

使用道具 举报

Bye2012 发表于 2010-10-20 21:10:48 | 显示全部楼层
关注           
回复

使用道具 举报

 楼主| 站站鱼 发表于 2010-10-21 11:19:07 | 显示全部楼层
cr180 发表于 2010-10-20 21:00
回复 站站鱼 的帖子

打开文件:source\module\forum\forum_forumdisplay.php

谢谢!我先记下了,不过这样无法指定某个版块使用特定的短标题,

最后通过,
<dd  style="float:left;width:450px;height:18px;white-space:nowrap;word-break:keep-all;overflow:hidden;text-overflow:ellipsis;">$thread[subject]</dd>

就是少了height:18px;试了几十遍才发现,我粗心到家,一直在迷惑是不是受到<th>的限制
.把高度忽略了!
回复

使用道具 举报

cr180 发表于 2010-10-21 11:35:13 | 显示全部楼层
回复 站站鱼 的帖子

<dl><dt></dt><dd></dd></dl>

是这样写的吗?
记得主题分类那个地方也要左浮动!
回复

使用道具 举报

 楼主| 站站鱼 发表于 2010-10-21 11:37:09 | 显示全部楼层
cr180 发表于 2010-10-21 11:35
回复 站站鱼 的帖子

主要原来没限制绝对高度,所以无法隐藏过长的标题
现在解决了,再次感谢!!
回复

使用道具 举报

残念 发表于 2010-12-22 09:14:55 | 显示全部楼层
再加上line-height:18px
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-6 18:05 , Processed in 0.123465 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表