Sticky Header Basic

Sticky Header Basic

Hard CSS Box Model & Sizing 22 views
Explanation Complexity

Problem Statement

Make a simple sticky header for meetcode.

Input Format

No input.

Output Format

Print the HTML+CSS code in one block.

Constraints

Use position: sticky and top: 0.

Input / Output Format

Input Format
No input.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use position: sticky and top: 0.

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>
    body { margin: 0; font-family: system-ui, Arial, sans-serif; }
    header { position: sticky; top: 0; background: #111; color: #fff; padding: 12px 16px; }
    main { padding: 16px; }
    .spacer { height: 1000px; }
  </style>
</head>
<body>
  <header>meetcode</header>
  <main>
    <p>Scroll to test sticky header.</p>
    <div class='spacer'></div>
  </main>
</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>
    body { margin: 0; font-family: system-ui, Arial, sans-serif; }
    header { position: sticky; top: 0; background: #111; color: #fff; padding: 12px 16px; }
    main { padding: 16px; }
    .spacer { height: 1000px; }
  </style>
</head>
<body>
  <header>meetcode</header>
  <main>
    <p>Scroll to test sticky header.</p>
    <div class='spacer'></div>
  </main>
</body>
</html>
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.