DedeCMS 调用一行2列字数智能控制方法,字数智能控制,碎片新闻
感谢作者的辛苦劳动!
DedeCMS 调用一行2列字数智能控制方法
本代码基于DedeCMS开发。
使用时请注意:
titlelen请大于整个li标签内的一半字符最好大于4-6个;
如果感觉显示效果不好或出错可以用短标题来做出调整;
调用代码:
|
|
|
1 |
Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com] |
|
2 |
{dede:arclist row='4' titlelen='20' } |
|
3 |
[field:global name=autoindex runphp="yes"](@me % 2 == 0)?@me="":@me="<li>·";[/field:global]<a href="[field:arcurl/]" target='_blank'>[field:array runphp='yes'] if (@me['shorttitle']=='') @me=@me['title'];else @me=@me['shorttitle'];[/field:array] </a>[field:global name=autoindex runphp="yes"](@me % 2 == 0)?@me="</li> |
|
4 |
":@me="";[/field:global] |
|
5 |
{/dede:arclist} |
效果演示:
|
|
|
01 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
02 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
03 |
<head> |
|
04 |
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> |
|
05 |
<title>dede调用一行2列字数智能控制方法</title> |
|
06 |
<style type="text/css"> |
|
07 |
<!-- |
|
08 |
body { |
|
09 |
margin: 0px; |
|
10 |
padding: 0px; |
|
11 |
} |
|
12 |
#cs { |
|
13 |
width: 200px; |
|
14 |
font-size: 12px; |
|
15 |
list-style-type: none; |
|
16 |
padding: 10px; |
|
17 |
background-color: #f5f5f5; |
|
18 |
border: 1px solid #c1c1c1; |
|
19 |
margin-top: 40px; |
|
20 |
margin-right: auto; |
|
21 |
margin-bottom: 40px; |
|
22 |
margin-left: auto; |
|
23 |
} |
|
24 |
#cs a { |
|
25 |
color: #333333; |
|
26 |
text-decoration: none; |
|
27 |
} |
|
28 |
#cs li { |
|
29 |
table-layout:fixed; |
|
30 |
width: 200px; |
|
31 |
overflow: hidden; |
|
32 |
text-overflow:ellipsis; |
|
33 |
height: 25px; |
|
34 |
line-height: 25px; |
|
35 |
} |
|
36 |
p { |
|
37 |
text-align: center; |
|
38 |
font-size: 12px; |
|
39 |
} |
|
40 |
--> |
|
41 |
</style> |
|
42 |
</head> |
|
43 |
<body> |
|
44 |
<ul id="cs"> |
|
45 |
<li>·<a href="#">这里是标题长度控制最</a> <a href="#">这里是标题长度控制最</a></li> |
|
46 |
<li>·<a href="#">这里是标题长</a> <a href="#">这里是标题长度控制最</a></li> |
|
47 |
</ul> |
|
48 |
<!-- |
|
49 |
下面是调用代码,可根据自己需要做相应的调整 |
|
50 |
{dede:arclist row='4' titlelen='20' } |
|
51 |
[field:global name=autoindex runphp="yes"](@me % 2 == 0)?@me="":@me="<li>·";[/field:global]<a href="[field:arcurl/]" target='_blank'>[field:array runphp='yes'] if (@me['shorttitle']=='') @me=@me['title'];else @me=@me['shorttitle'];[/field:array] </a>[field:global name=autoindex runphp="yes"](@me % 2 == 0)?@me="</li> |
|
52 |
":@me="";[/field:global] |
|
53 |
{/dede:arclist} |
|
54 |
--> |
|
55 |
<p>DedeCMS 调用一行2列字数智能控制方法<br /><br /> |
|
56 |
|
|
57 |
本代码基于DedeCMS开发。<br /><br /> |
|
58 |
<font color="#FF0000">使用时请注意:</font><br /><br /> |
|
59 |
<font color="#FF0000">titlelen请大于整个li标签内的一半字符最好大于2-4个;</font><br /><br /> |
|
60 |
<font color="#FF0000">如果感觉显示效果不好或出错可以用短标题来做吃调整;</font><br /><br /> |
|
61 |
版权归作者所有,转载请标明!<br /><br /> |
|
62 |
网站支持<a href="http://www.dedesos.com">织梦帮</a></p> |
|
63 |
</body> |
|
64 |
</html> |