Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> html { height: 100%; } body { display: flex; flex-direction: column; height: 100vh; } .content { flex: 1 0 auto; padding: 20px; } .footer { flex-shrink: 0; padding: 20px; } * { box-sizing: border-box; } body { margin: 0; font: 16px Sans-Serif; } h1 { margin: 0 0 20px 0; } p { margin: 0 0 20px 0; } footer { background: #42A5F5; color: white; } </style> </head> <body> <div class="content"> <h1>Sticky Footer with Flexbox</h1> <p>Example</p> </div> <footer class="footer"> Footer </footer> </body> </html>