Grid Item Overlap
CSS
Hard
3 views
Problem Description
Place a badge on top of a card using grid overlap.
Output Format
Print the HTML+CSS code in one block.
Constraints
Put both elements in the same grid cell and use z-index.
Official Solution
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>meetcode</title>
<style>
.stack { display: grid; width: 360px; }
.card { grid-area: 1 / 1; border: 1px solid #eee; border-radius: 14px; padding: 16px; }
.badge { grid-area: 1 / 1; justify-self: end; align-self: start; margin: 12px; background: #0b5; color: #fff; padding: 4px 10px; border-radius: 999px; font-size: 12px; z-index: 1; }
</style>
</head>
<body>
<div class='stack'>
<div class='badge'>NEW</div>
<div class='card'>meetcode CSS practice</div>
</div>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!