效果图
下面就来说一下dede中具体怎么实现
1.在要显示的页面中加入以下代码
<div class="pright">
<dl class="tbox light"><a href='/tags.php'><strong>标签云</strong></a></dl>
<dl class="tbox light tagy">
{dede:tag row='40' getall='1' sort='hot'}
<a href='[field:link/]' title="[field:tag /]([field:total /])" style="[field:total runphp=yes]@me=getTagStyle();[/field:total]">[field:tag /]</a>
{/dede:tag}
</dl>
</div>
2.修改根目录下include/common.func.php文件加入以下代码
function getTagStyle(){
$minFontSize=5; //最小字体大小,可根据需要自行更改
$maxFontSize=18; //最大字体大小,可根据需要自行更改
return 'font-size:'.($minFontSize+lcg_value()*(abs($maxFontSize-$minFontSize))).'px;background-color:#'.dechex(rand(0,255)).dechex(rand(0,196)).dechex(rand(0,255));
}
这个位置不是固定的,可以加到结尾。但也不要加到别的function 里。
3.修改根目录下/templets/default/style/layout.css文件加入以下代码
.tagy a{
color:#fff;//字体颜色
background-color: #27989D;//默认背景颜色
padding: 3px;//内间距
white-space: nowrap;//分段
line-height: 24px;//外距
}
