首页  >  文章  >  php教程  >  PHP 生成一个颜色选择面板

PHP 生成一个颜色选择面板

PHP中文网
PHP中文网原创
2016-05-25 17:15:571851浏览

webcolor.php   

<html>
<head>
<title>Web-Safe Color Palette</title>
</head>
<body>
<table>
<tr>
<?php
     $i = 1;
     $row_size = 18;
   
     for($red = 0; $red <= 5; $red++)
     for($green = 0; $green <= 5; $green++) {
          for($blue = 0; $blue <= 5; $blue++)
          {
               $red_hex = str_pad(dechex($red * 51), 2, "0", STR_PAD_LEFT);
               $green_hex = str_pad(dechex($green * 51), 2, "0", STR_PAD_LEFT);
               $blue_hex = str_pad(dechex($blue * 51), 2, "0", STR_PAD_LEFT);
               $hex_color = $red_hex . $green_hex . $blue_hex;
   
               print("<td bgcolor=\"#$hex_color\" width=\"15\"> </td>");
   
               if(($i % $row_size) == 0)
                    print("</tr><tr>");
   
               $i++;
          }
     }    
?>
</tr>
</table>
</body>
</html>

                   

                   

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn