In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how dedecms tag tags achieve random color and font size. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
How do dedecms tag tags achieve random color and font size?
What we want to achieve is: the effect of the tag cloud, including the label has different colors and font sizes, the color and font size are displayed randomly, and the code can be changed to control its range, which looks good. Next, let's look at the implementation method. You can't miss it if you're interested.
Function description:
To achieve the effect of tag cloud, including tags have different colors and font sizes, colors and font sizes are randomly displayed, you can change the code to control its range.
Achieve the effect of DeDeCms tag cloud, including tags have different colors and font sizes, etc., colors and font sizes are randomly displayed, you can change the code to control its range.
Modify method:
1. Add the following function to / include/common.func.php.
The code is as follows:
Function getTagStyle () {$minFontSize=8; / / minimum font size, you can change $maxFontSize=18; / / maximum font size as needed, and you can change return 'font-size:'. ($minFontSize+lcg_value () * (abs ($maxFontSize-$minFontSize).' px;color:#'.dechex (rand (0255)) .dechex (rand (0196)) .dechex (rand (0255));}
The function is used to output random styles, including font-size and color.
If you want to specify that only a few font sizes are displayed instead of being completely random, change the above function code to:
The code is as follows:
Function getTagStyle () {$sizearray = array); / / Custom font size, you can modify return 'font-size:'.$ sizearray as needed.' pt;color:#'.dechex (rand (0255)) .dechex (rand (0196)) .dechex (rand (0255));}
2. Call the tag in the template with the following code.
The code is as follows:
{dede:tag row='45' getall='1' sort='hot'} [field:tag /] {/ dede:tag}
3. Generate the corresponding html,OK in the dede backend, depending on the effect.
Thank you for reading! On the dedecms tag tag to achieve random color and font size method to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.