I'm trying to put sticky footer. I searched many examples and tried but failed. This link is the example what I tried. https://css-tricks.com/snippets/css/sticky-footer/
When I paste same code to my html, footer does not stick to bottom but just stay center of the main div or just pushing out main contents and stay inside of main div, I wonder if there is something wrong with my HTML.
This is CSS.
*, *:before, *:after {
box-sizing: inherit;
}
html {
-webkit-font-smoothing: antialiased;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
line-height: 1.5;
}
header {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 9999;
padding: 10px 20px;
}
.main{
width: 70%;
}
This is HTML.
<body>
<header>
</header>
<div class="main">
</div>
<footer>
</footer>
</body>
Edited 1: I added picture.
The gray boxes are contents that supposed stay inside of main, and I want the footer stays the end of the main div. However, till now footers keep displayed middle of browser with contents.