Realize the effect of Zhimeng DedeCMS colorful label cloud, including labels with different colors and font sizes. The colors and font sizes are displayed randomly, and the code can be changed to control its range.
1. Add the following function to/include/common. func.php to output random styles, including font size and color.
function getTagStyle()
{
$minFontSize=12; // The minimum font size can be changed as needed
$maxFontSize=25; // The maximum font size can be changed according to needs
return
'font-size:’. ($minFontSize+lcg_value()*(abs($maxFontSize-$minFontSize))).’ px; color:#’.dechex(rand(0,255)).dechex(rand(0,196)).dechex(rand(0,255));
}
2. The following similar method is used when calling tags in the template page htm.
<a href=’[field:link/]' title=”[field:tag /]” style=”[field:total runphp=yes]@me=getTagStyle(); [/field:total]“>[field:tag /]</a>
Additional instructions
If you want to specify that only a few font sizes are displayed instead of being completely random, please replace the function code in Step 1 with
$sizearray = array('8′,’9′,’10′,’11′,’12′,’20′); // Custom font size
It can be modified as needed
return 'font-size:’.$ sizearray[rand(0,count($sizearray))].’ pt; color:#’.dechex(rand(0,255)).dechex(rand(0,196)).dechex(rand(0,255));
Statement: All articles on this site, unless otherwise specified or marked, are originally published on this site. No individual or organization is allowed to copy, embezzle, collect and publish the content of this website to any website, book and other media platforms without the consent of this website. If the content of this website infringes upon the legitimate rights and interests of the original author, please contact us for handling.