Absolute Badge on Card

Absolute Badge on Card

Hard CSS Box Model & Sizing 24 views
Explanation Complexity

Problem Statement

Place a 'NEW' badge at top-right inside a card.

Input Format

No input.

Output Format

Print the HTML+CSS code in one block.

Constraints

Use position: relative on card and absolute on badge.

Input / Output Format

Input Format
No input.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use position: relative on card and absolute on badge.

Examples

Input:
Output:
(HTML+CSS code)

Example Solution (Public)

CSS
<!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>

Official Solution Code

<!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>
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.