Advertisement
mtpiercey

Infinitely-scrolling background demo

Sep 7th, 2020
2,586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.88 KB | None | 0 0
  1. <template>
  2.   <div class="container">
  3.     <div class="homepage--hero">
  4.       <div class="homepage--hero--background"></div>
  5.     </div>
  6.   </div>
  7. </template>
  8.  
  9. <style lang="scss">
  10. @keyframes slide {
  11.   0% {
  12.     transform: translate3d(0, 0, 0);
  13.   }
  14.   100% {
  15.     transform: translate3d(-2000px, 0, 0);
  16.   }
  17. }
  18.  
  19. .homepage {
  20.   &--hero {
  21.    position: relative;
  22.     width: 100vw;
  23.     height: 65vh;
  24.     overflow-x: hidden !important;
  25.  
  26.     &--background {
  27.      position: absolute;
  28.       top: 0;
  29.       z-index: -1;
  30.       width: 6000px;
  31.       height: 65vh;
  32.       background: url('background.svg') repeat-x;
  33.       background-position: center center;
  34.  
  35.       @media (prefers-reduced-motion: reduce) {
  36.         animation: none;
  37.       }
  38.  
  39.       @media (prefers-reduced-motion: no-preference) {
  40.         animation: slide 45s linear infinite;
  41.       }
  42.  
  43.     }
  44.   }
  45. }
  46. </style>
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement