Created
March 15, 2022 08:50
-
-
Save abdulbasit-dev/ff52d795542b74fb35a116b1cd2172fd to your computer and use it in GitHub Desktop.
CSS to make footer stay at bottom of the page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<header contentEditable>Header</header> | |
<article contentEditable>Content</article> | |
<footer contentEditable>Footer</footer> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 1 flex-box */ | |
body { | |
height: 100vh !important; | |
margin: 0 !important; | |
} | |
/* Trick */ | |
body { | |
display: flex !important; | |
flex-direction: column !important; | |
} | |
footer { | |
margin-top: auto !important; | |
} | |
/* Grid */ | |
body{ | |
min-height: 100vh; | |
margin: 0; | |
display: grid; | |
grid-template-rows: auto 1fr auto; | |
} | |
header{ | |
min-height:50px; | |
background:lightcyan; | |
} | |
footer{ | |
min-height:50px; | |
background:PapayaWhip; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment