Pin Footer to Bottom

How to pin footer to bottom of page?
I’m really bad in CSS, so ask such obvious question

CSS:

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    transition: all 0.25s linear;
}

.header-container {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.theme-switch {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    height: 50px;
    background-color: #2A9D8F;
    color: #E9C46A;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1em;
}

.main-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 15px;
}

.content-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 20);
}

h1 {
    font-size: 2.5em;
    text-align: center;
    padding: 20px;
}

.filter-button {
    display: block;
    width: 200px;
    height: 50px;
    margin: 20px auto;
    background-color: #2A9D8F;
    color: #E9C46A;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1em;
}

a {
    text-decoration: none;
    color: inherit;
}

.posts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem;
    flex-grow: 1;
}

.post {
    background-color: #F4A261; /* Tertiary color of Early Spring theme */
    padding: 20px;
    border-radius: 15px;
    transition: transform .2s; /* Animation */
}

.post:hover {
    transform: scale(1.02); /* Slightly enlarge the post on hover */
}

footer {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    background-color: #2A9D8F;
    color: #E9C46A;
    padding: 20px 0;
    bottom: 0;
    width: 100%;
    left: 0;
    box-sizing: border-box;
}

Welcome to the community!
No question is a bad question.
This is how we all learn.

I suggest trying a position of fixed in your footer selector.

You can learn more about the footer position here.

Happy coding! :slight_smile:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.