Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <html>
  2. <head>
  3.  
  4. <style>
  5. .abc
  6. {
  7. margin: 45px;
  8. }
  9. </style>
  10.  
  11. </head>
  12. <body onload="click()">
  13.  
  14. <div id="abc" class="abc" style=" height: 500px; width: 500px; border: 1px solid black;">
  15. <div id="abc1" class="abc" style=" height: 400px; width: 400px; border: 1px solid black;">
  16. <div id="abc2" class="abc" style=" height: 300px; width: 300px; border: 1px solid black;">
  17. <div id="abc3" class="abc" style=" height: 200px; width: 200px; border: 1px solid black;">
  18. <div id="abc4" class="abc" style=" height: 100px; width: 100px; border: 1px solid black;">
  19.  
  20. </div></div></div></div></div>
  21.  
  22. <script>
  23. function click(){
  24. setInterval(function(){
  25. //setting the colors to be displayed in the square
  26. var bgcolorlist=new Array("red","green", "blue", "cyan", "violet", "orange", "indigo", "Grey", "yellow");
  27. var a=document.getElementById('abc');
  28. var a1=document.getElementById('abc1');
  29. var a2=document.getElementById('abc2');
  30. var a3=document.getElementById('abc3');
  31. var a4=document.getElementById('abc4');
  32. var a5=document.getElementById('abc5');
  33.  
  34. //random() to make colours display at random
  35. a.style.background=bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)]
  36. a1.style.background=bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)]
  37. a2.style.background=bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)]
  38. a3.style.background=bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)]
  39. a4.style.background=bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)]
  40. a5.style.background=bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)]
  41. },1000);
  42. }
  43. </script>
  44. </body>
  45. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement