Toggle navigation
☰
HTML
CSS
Scripting
Database
<!doctype html> <title>Example</title> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; font-family: sans-serif; background-color: #f0f0f0; } /* The window that crops the overflow */ .marquee-container { width: 600px; background-color: white; padding: 20px 0; overflow: hidden; /* Crucial */ position: relative; box-shadow: 0 4px 6px rgba(0,0,0,0.1); /* Adds a slight fade to the edges using a CSS mask */ -webkit-mask-image: linear-gradient( to right, transparent, black 10%, black 90%, transparent ); mask-image: linear-gradient( to right, transparent, black 10%, black 90%, transparent ); } /* The track that holds all the items. Note it contains TWO sets of identical items. We use flex-shrink: 0 so the track doesn't naturally crush its children to fit. */ .marquee-track { display: flex; gap: 30px; /* Space between logos */ width: max-content; /* To calculate the animation: We animate the track exactly 50% of its width. Because the track contains exactly two copies of the same items, shifting it left by 50% perfectly aligns copy B onto the starting spot of copy A. */ animation: scroll-left 10s linear infinite; } /* Hovering the container stops the track for easier reading/clicking */ .marquee-container:hover .marquee-track { animation-play-state: paused; } .marquee-item { background-color: #007bff; color: white; padding: 10px 20px; border-radius: 4px; font-weight: bold; flex-shrink: 0; } @keyframes scroll-left { from { transform: translateX(0); } to { transform: translateX(calc(-50% - 15px)); /* The -15px is exactly half of the gap space to make the math seamless */ } } @media (prefers-reduced-motion: reduce) { .marquee-track { animation: none; /* Stops the scrolling */ flex-wrap: wrap; /* Allows them to stack instead of hiding off-screen */ width: 100%; gap: 10px; justify-content: center; } .marquee-container { /* Removes the mask so the wrapped items are visible on the edges */ mask-image: none; -webkit-mask-image: none; } .marquee-item[aria-hidden="true"] { display: none; /* Hide duplicates */ } } </style> <div class="marquee-container" tabindex="0"> <div class="marquee-track"> <!-- FIRST SET --> <div class="marquee-item">Logo 1</div> <div class="marquee-item">Logo 2</div> <div class="marquee-item">Logo 3</div> <div class="marquee-item">Logo 4</div> <div class="marquee-item">Logo 5</div> <!-- EXACT DUPLICATE SECOND SET (Used for seamless looping) --> <div class="marquee-item" aria-hidden="true">Logo 1</div> <div class="marquee-item" aria-hidden="true">Logo 2</div> <div class="marquee-item" aria-hidden="true">Logo 3</div> <div class="marquee-item" aria-hidden="true">Logo 4</div> <div class="marquee-item" aria-hidden="true">Logo 5</div> </div> </div>