Absolute Badge on Card
CSS
Hard
2 views
Problem Description
Place a 'NEW' badge at top-right inside a card.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use position: relative on card and absolute on badge.
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>
.card { width: 360px; padding: 16px; border: 1px solid #eee; border-radius: 14px; position: relative; }
.badge { position: absolute; top: 12px; right: 12px; background: #0b5; color: #fff; padding: 4px 8px; border-radius: 999px; font-size: 12px; }
</style>
</head>
<body>
<div class='card'>
<span class='badge'>NEW</span>
<h2>meetcode</h2>
<p>Fresh questions added.</p>
</div>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!