Arno

Random color stripes. Wonderful random color stripes (in PHP).

<?php

$numBoxes = 7;
$totalHeight = 390;
$top=0;

$colors = array(
  '#ccff33',
  '#cc6600',
  '#009933',
  '#6699cc',
  '#ff3399',
  '#66cc33',
  '#ffcc00',
  '#996600',
  '#6600cc'
);
srand(time());
mt_srand(time());
$randColor = array_rand($colors, $numBoxes);
foreach ($randColor as $one) {
  $boxHeight = (int)((mt_rand(40, 140)/100)*($totalHeight/$numBoxes));
  echo '
  <div style="
    position:absolute;
    left:0px; top:'.$top.'px;
    width:20px;
    height:'.$boxHeight.'px;
    z-index:1;
    background-color: '.$colors[$one].';"></div>
  ';
  $numBoxes--;
  $totalHeight -= $boxHeight;
  $top += $boxHeight;
}

?>
This entry was posted in Code, Sites. Bookmark the permalink.

Comments are closed.