Sticky Footer with Flex
CSS
Hard
3 views
Problem Description
Make a layout where footer stays at bottom when content is short.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use min-height 100vh and flex column.
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>
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; font-family: system-ui, Arial, sans-serif; }
header, footer { padding: 12px 16px; background: #111; color: #fff; }
main { flex: 1; padding: 16px; }
</style>
</head>
<body>
<header>meetcode</header>
<main>
<p>Short content.</p>
</main>
<footer>Footer stays down</footer>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!