头像

PHP 生成一个颜色选择面板

2018-04-17 10:57:18 来源:PHP代码   浏览()   评论 ( 0 )   

<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>


标签: php
声明:转载请注明来源(PHP代码)并保留原文链接:http://www.phpdaima.com//wenzhang-96.html
广告不存在
评论0

后面还有条评论,点击查看>>

温馨提示:为规范评论内容,垃圾评论一律封号...