PHP generates tag tag functions of different colors and sizes_PHP tutorial

WBOY
Release: 2016-07-21 16:12:56
Original
1006 people have browsed it

Copy code The code is as follows:

function getTagStyle(){
$minFontSize=8; //Minimum font size , you can change it as needed
$maxFontSize=18; //Maximum font size, you can change it as needed
return 'font-size:'.($minFontSize+lcg_value()*(abs($maxFontSize- $minFontSize))).'px;color:#'.dechex(rand(0,255)).dechex(rand(0,196)).dechex(rand(0,255));
}

The function of this function is to output random styles, including font-size and color.

If you want to specify only a few font sizes to be displayed instead of completely random, please modify the above function code to:

Copy code The code is as follows:

function getTagStyle(){
$sizearray = array('8',' 9','10','11','12','20'); //Customize the font size, you can modify it as needed
return 'font-size:'.$sizearray[rand(0, count($sizearray))].'pt;color:#'.dechex(rand(0,255)).dechex(rand(0,196)).dechex(rand(0,255));
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/313587.htmlTechArticleCopy the code as follows: function getTagStyle(){ $minFontSize=8; //Minimum font size, as needed Change it yourself $maxFontSize=18; //Maximum font size, you can change it as needed...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template