You can achieve a sticky footer using a combination of CSS Flexbox and HTML. Here’s an example:
html
Copy code
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Sticky Footer</title><style>html, body {
height: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
.content {
flex: 1;
}
.footer {
background-color: #f1f1f1;
text-align: center;
padding: 10px;
}
</style>
</head>
<body><div class="content"><!-- Page content goes here --></div><div class="footer">
Sticky Footer
</div>
</body>
</html>
In this example, flex: 1
applied to the .content
class ensures that the content area expands to take up the available space, pushing the footer to the bottom when there is little content.