Advertisement
StefiIOE

Untitled

Jun 22nd, 2020
1,107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <script src = "jquery-3.5.1.min.js"></script>
  5.     <script>
  6.         $(document).ready(function () {
  7.  
  8.  
  9.             var data = "<div class='kol'><div class='box'></div></div>";
  10.             for (var i = 1; i <= 3; i++) {
  11.                 $('.container').append(data);
  12.             }
  13.             $('.kol .box').each(function getTheColor() {
  14.  
  15.                 var colorR = Math.floor((Math.random() * 256));
  16.                 var colorG = Math.floor((Math.random() * 256));
  17.                 var colorB = Math.floor((Math.random() * 256));
  18.                 $(this).css("background-color", "rgb(" + colorR + "," + colorG + "," + colorB + ")");
  19.  
  20.  
  21.             });
  22.         });
  23.  
  24.  
  25.  
  26.  
  27.     </script>
  28.     <style>
  29.         *
  30.         {
  31.             margin: 0;
  32.         }
  33.         .container
  34.         {
  35.             padding: 10px;
  36.             width: 40%;
  37.             overflow: auto;
  38.             position: relative;
  39.         }
  40.         .kol
  41.         {
  42.             width: calc(100%/3);
  43.             float: left;
  44.             }
  45.         .box
  46.         {
  47.             height: 200px;
  48.             width: 200px;
  49.             background-color: #aaaaaa;
  50.  
  51.         }
  52.     </style>
  53. </head>
  54. <body>
  55. <div class="container"></div>
  56.  
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement