Advertisement
Smokli

Untitled

Oct 9th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. <style id="my-style">
  6. html,
  7. body,
  8. #bubbles { height: 100% }
  9. body { overflow: hidden }
  10. #bubbles { padding: 100px 0 }
  11. .bubble {
  12. background: #ffb200;
  13. border-radius: 50%;
  14. -moz-border-radius: 200px;
  15. -webkit-border-radius: 200px;
  16. position: absolute;
  17. }
  18. @-webkit-keyframes moveclouds {
  19. 0% {
  20. top: 1200px;
  21. }
  22. 100% {
  23. top: -100px;
  24. }
  25. }
  26.  
  27. @-webkit-keyframes sideWays {
  28. 0% {
  29. margin-left:0px;
  30. }
  31. 100% {
  32. margin-left:650px;
  33. }
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <div id="bubbles">
  39.  
  40. </div>
  41. <script src="JavaScript1.js"></script>
  42. </body>
  43. </html>
  44.  
  45.  
  46.  
  47.  
  48. var styleTag = document.getElementById('my-style');
  49. var sheet = styleTag.sheet ? styleTag.sheet : styleTag.styleSheet;
  50.  
  51. for (var i = 0; i < 1000; i++) {
  52. var bubble = document.createElement('div');
  53. var randomClass = 'x' + (Math.floor(Math.random() * 1000) + 1);
  54. bubble.className = ('bubble ' + randomClass);
  55. var randomSize = (Math.floor(Math.random() * 100) + 1) + 'px';
  56. bubble.style.width = randomSize;
  57. bubble.style.height = randomSize;
  58. bubble.style.left = (Math.floor(Math.random() * 1200) + 1) + 'px';
  59. bubble.style.backgroundColor = generateRandomColor();
  60. bubble.style.opacity = Math.random().toFixed(1);
  61. bubble.style.border = generateRandomBorder();
  62. randomVerticalSpeed = (Math.random() * 100).toFixed(1) + 2;
  63. randomHorizontalSpeed = (Math.random() * 100).toFixed(1) + 2;
  64.  
  65. sheet.addRule(('.' + randomClass), '-webkit-animation: moveclouds ' + randomVerticalSpeed +'s linear infinite, sideWays ' + randomHorizontalSpeed +'s ease-in-out infinite alternate', 0);
  66. document.getElementById('bubbles').appendChild(bubble);
  67.  
  68. }
  69.  
  70. function generateRandomColor() {
  71. var r = Math.floor(Math.random() * 255) + 1;
  72. var g = Math.floor(Math.random() * 255) + 1;
  73. var b = Math.floor(Math.random() * 255) + 1;
  74. var rgb = 'rgb(' + r + ', ' + g + ',' + b + ')';
  75. return rgb;
  76. }
  77. function generateRandomBorder() {
  78. var width = (Math.floor(Math.random() * 3) + 1) + 'px solid ';
  79. return width + generateRandomColor();
  80. }
  81. setInterval(function () {
  82. var divs = document.getElementsByTagName('div');
  83. for (var i = 0; i < divs.length - 1; i++) {
  84. divs[i].style.backgroundColor = generateRandomColor();
  85. divs[i].style.border = generateRandomBorder();
  86. var randomSize = (Math.floor(Math.random() * 100) + 1) + 'px';
  87. divs[i + 1].style.width = randomSize;
  88. divs[i + 1].style.height = randomSize;
  89. }
  90. }, 200);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement