-
CSS infinite scroll animation
HTML
CSS
JavaScript
/* Vertical and Horizontal Screen Centering */ .scroll-wrap { display: flex; align-items: center; /* Middle align vertically on screen */ justify-content: center; /* Center horizontally */ min-height: 100vh; /* Uses full screen height */ background-color: #0d0d11; width: 100%; overflow: hidden; scale:0.7 } /* Ticker Window Mask */ .scroll-container { overflow: hidden; width: 100%; padding: 20px 0; position: relative; } /* Linear Moving Track */ .scroll-content { display: flex; gap: 24px; padding-right: 24px; /* Matches gap value to eliminate layout snapping */ width: max-content; animation: scroll-left 25s linear infinite; } /* 2:4 Ratio Card Container */ .item { flex-shrink: 0; width: 180px; /* Base width of card */ aspect-ratio: 2 / 4; /* Locks shape to portrait proportion */ border-radius: 14px; overflow: hidden; /* Clips image edges to border-radius */ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.05); /* Fallback color/gradient if images take a moment to load */ background: linear-gradient(145deg, #1e1e24, #141418); transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1); } /* Image Scaling Rules */ .item img { width: 100%; height: 100%; object-fit: cover; /* Fills container safely without distortion */ object-position: center; /* Keeps focal area centered */ display: block; } /* Interaction Effects */ .scroll-container:hover .scroll-content { animation-play-state: paused; } .item:hover { transform: scale(1.04); /* Elegant scale focus state */ border-color: rgba(255, 255, 255, 0.2); } /* Animation Sequence */ @keyframes scroll-left { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); /* Resets invisibly halfway through */ } }
Live Preview