<div class="video-grid">
<div class="video-card">
<div class="thumbnail">
<img src="https://placehold.co/600x338/1e293b/ffffff?text=Video+1" alt="Thumb">
<div class="play-icon">▶</div>
</div>
<div class="meta">
<h3>Intro to CSS</h3>
<span>10:24</span>
</div>
</div>
<div class="video-card">
<div class="thumbnail">
<img src="https://placehold.co/600x338/334155/ffffff?text=Video+2" alt="Thumb">
<div class="play-icon">▶</div>
</div>
<div class="meta">
<h3>Advanced Grids</h3>
<span>15:02</span>
</div>
</div>
</div>* { box-sizing: border-box; }
body {
font-family: system-ui, "Segoe UI", sans-serif;
background: #0f172a;
padding: 20px;
display: flex;
justify-content: center;
}
.video-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 20px;
width: 100%;
max-width: 900px;
}
.video-card {
background: #1e293b;
border-radius: 12px;
overflow: hidden;
transition: transform 0.2s;
}
.video-card:hover { transform: translateY(-4px); }
.thumbnail {
width: 100%;
/* The Magic: Force 16/9 ratio */
aspect-ratio: 16 / 9;
position: relative;
background: #000;
}
.thumbnail img {
width: 100%;
height: 100%;
object-fit: cover;
opacity: 0.8;
transition: opacity 0.2s;
}
.video-card:hover img { opacity: 1; }
.play-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 40px;
height: 40px;
background: rgba(0,0,0,0.6);
color: white;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
font-size: 14px;
backdrop-filter: blur(4px);
}
.meta {
padding: 12px;
display: flex;
justify-content: space-between;
align-items: center;
color: white;
}
h3 { margin: 0; font-size: 1rem; font-weight: 500; }
span { font-size: 0.85rem; color: #94a3b8; }Nothing to show yetType HTML, CSS or JavaScript and your page appears here.
Click any element to find its code Esc
Check this code before you run it
It came from a shared link. It runs with fewer permissions, so it cannot open pop-ups, submit forms or start downloads.
0.00s / 0.00s
Nothing has animated yet. Hover, click or type in the preview and each CSS animation, transition or
element.animate() call shows up here as it plays.