sacred_fox

previewer for pictSQUARE, originally by @file_c

Dec 27th, 2020 (edited)
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.32 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. @keyframes walk {
  5.   25% {background-position-x: 0%;}
  6.   50% {background-position-x: 50%;}
  7.   75% {background-position-x: 100%;}}
  8. div{display: inline-block;
  9.   background: url(image.png) no-repeat 50% 0;
  10.   animation: walk 1s infinite steps(1);
  11.   -ms-interpolation-mode: nearest-neighbor;
  12.   image-rendering: crisp-edges;
  13.   image-rendering: pixelated;
  14. }
  15. div{width:32px;height:32px;}
  16. div:nth-of-type(2n){width:64px;height:64px;background-size: 300%, auto;}
  17. div:nth-of-type(3),div:nth-of-type(4){background-position-y: 33.3%;}
  18. div:nth-of-type(5),div:nth-of-type(6){background-position-y: 66.7%;}
  19. div:nth-of-type(7),div:nth-of-type(8){background-position-y: 100%;}
  20. </style>
  21. <script>
  22. window.onload = () => {
  23.   let sel = document.getElementsByTagName('select')[0];
  24.   sel.onchange = () => {
  25.     let divs = document.getElementsByTagName('div');
  26.     let len = divs.length;
  27.     for (let i = 0; i < len; i++) {
  28.      divs[i].style.backgroundImage = 'url(' + sel.value + ')';
  29.    }
  30.  }
  31.  sel.onchange();
  32. }
  33. </script>
  34. </head>
  35. <body>
  36. <select>
  37. <option>image.png</option>
  38. <option>image1.png</option>
  39. <option>image2.png</option>
  40. <option>image3.png</option>
  41. </select><br />
  42. <div></div><div></div><br />
  43. <div></div><div></div><br />
  44. <div></div><div></div><br />
  45. <div></div><div></div><br />
  46. </body>
  47. </html>
  48.  
Add Comment
Please, Sign In to add comment