Video Grid /* Reset & Base Styles */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; background-color: #f5f5f5; padding: 20px 0; } /* Video Grid Layout */ .video-row { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin: 30px auto; max-width: 1200px; padding: 0 10px; } .video-column { position: relative; width: 116px; height: 207px; overflow: hidden; border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); transition: transform 0.3s ease, box-shadow 0.3s ease; cursor: pointer; } .video-column:hover { transform: scale(1.08); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); } .video-bg { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; } /* Play Button */ .play-button { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; background: rgba(255, 255, 255, 0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 2; opacity: 1; transition: opacity 0.3s ease; } .play-button:before { content: ''; display: inline-block; margin-left: 4px; border-style: solid; border-width: 8px 0 8px 12px; border-color: transparent transparent transparent #000; } /* Responsive: Mobile Optimization */ @media (max-width: 480px) { .video-row { flex-direction: column; align-items: center; gap: 16px; } .video-column { width: 90vw; max-width: 300px; height: auto; aspect-ratio: 116 / 207; /* Maintain original aspect ratio */ margin: 10px 0; } .video-column:hover { transform: scale(1.05); } /* Larger play button for touch */ .play-button { width: 50px; height: 50px; } .play-button:before { border-width: 10px 0 10px 16px; margin-left: 6px; } } Your browser does not support the video tag. Your browser does not support the video tag. Your browser does not support the video tag. document.querySelectorAll('.video-column').forEach(column => { const video = column.querySelector('video'); const button = column.querySelector('.play-button'); // Initial state: show play button if video is paused button.style.opacity = video.paused ? '1' : '0'; // Click to play/pause function toggleVideo() { if (video.paused) { video.play(); } else { video.pause(); } } column.addEventListener('click', toggleVideo); // Keyboard support column.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggleVideo(); } }); // Sync play button visibility video.addEventListener('play', () => { button.style.opacity = 0; }); video.addEventListener('pause', () => { button.style.opacity = 1; }); // Show play button on hover (if paused) column.addEventListener('mouseenter', () => { if (video.paused) button.style.opacity = '1'; }); column.addEventListener('mouseleave', () => { if (!video.paused) button.style.opacity = '0'; }); }); .video-row { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin: 30px auto; max-width: 1200px; padding: 0 10px; } .video-column { position: relative; width: 116px; height: 207px; overflow: hidden; border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); transition: transform 0.3s ease, box-shadow 0.3s ease; cursor: pointer; } .video-column:hover { transform: scale(1.08); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); } .video-bg { width: 100%; height: 100%; object-fit: cover; /* Fills container, crops as needed */ border-radius: 12px; } /* Play button - centered */ .play-button { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; background: rgba(255, 255, 255, 0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 2; } .play-button:before { content: ''; display: inline-block; margin-left: 4px; border-style: solid; border-width: 8px 0 8px 12px; border-color: transparent transparent transparent #000; } /* Responsive: Stack vertically on small screens */ @media (max-width: 480px) { .video-row { flex-direction: column; align-items: center; } .video-column { margin: 10px 0; } } Your browser does not support the video tag. Your browser does not support the video tag. Your browser does not support the video tag. // Optional: Add click to play/pause document.querySelectorAll('.video-column').forEach(column => { const video = column.querySelector('video'); const button = column.querySelector('.play-button'); column.addEventListener('click', () => { if (video.paused) { video.play(); button.style.opacity = 0; } else { video.pause(); button.style.opacity = 1; } }); video.addEventListener('play', () => (button.style.opacity = 0)); video.addEventListener('pause', () => (button.style.opacity = 1)); });