Advertisement
Guest User

Hex Colour Code Generator

a guest
Apr 25th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.77 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Hex Colour Code Generator</title>
  6. <script type="php">
  7.     <?php function generateRandomString($length = 6) {
  8.    $characters = '0123456789ABCDEF';
  9.    $charactersLength = strlen($characters);
  10.    $randomString = '';
  11.    for ($i = 0; $i < $length; $i++) {
  12.        $randomString .= $characters[rand(0, $charactersLength - 1)];
  13.    }
  14.    return $randomString;
  15. }
  16.  
  17.     $hexCode = generateRandomString(); ?>
  18.     </script>
  19. <style>
  20.     body {  background-color: #<?php echo $hexCode; ?>;
  21.         font-family: Arial, Helvetica, sans-serif;
  22.         font-size: 6em;
  23.         color: #FFF;
  24.         padding-left: 40px;
  25.         padding-top: 20px;
  26.     }
  27.  
  28.     p { padding: 0;
  29.         margin: 0;}
  30. </style>
  31. </head>
  32.  
  33. <body>
  34. <p>#<?php echo $hexCode ?></p>
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement