index.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link rel="stylesheet" href="../resources/css/base.css" />
  5. <link rel="stylesheet" href="./colors.css" />
  6. <style>
  7. * {
  8. box-sizing: border-box;
  9. }
  10. .element {
  11. background-color: #FFDC00;
  12. width: 80%;
  13. max-width: 300px;
  14. padding: 0 15px;
  15. font-size: 20px;
  16. box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
  17. }
  18. @media (max-width: 380px) {
  19. .element {
  20. font-size: 16px;
  21. }
  22. }
  23. .bit {
  24. width: 10vw;
  25. height: 10vw;
  26. float: left;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div class="element">
  32. <p>This element is tethered to the middle of the visible part of the body.</p>
  33. <p>Inspect the element to see how Tether decided
  34. to use <code>position: fixed</code>.</p>
  35. </div>
  36. <script src="//github.hubspot.com/tether/dist/js/tether.js"></script>
  37. <script>
  38. new Tether({
  39. element: '.element',
  40. target: document.body,
  41. attachment: 'middle center',
  42. targetAttachment: 'middle center',
  43. targetModifier: 'visible'
  44. });
  45. </script>
  46. <script>
  47. // Random colors bit, don't mind this
  48. colors = ['navy', 'blue', 'aqua', 'teal', 'olive', 'green', 'lime',
  49. 'yellow', 'orange', 'red', 'fuchsia', 'purple', 'maroon'];
  50. curColors = null;
  51. for(var i=300; i--;){
  52. if (!curColors || !curColors.length)
  53. curColors = colors.slice(0);
  54. var bit = document.createElement('div')
  55. var index = (Math.random() * curColors.length)|0;
  56. bit.className = 'bit bg-' + curColors[index]
  57. curColors.splice(index, 1);
  58. document.body.appendChild(bit);
  59. }
  60. </script>
  61. </body>
  62. </html>