Footer is an effective way to organize a lot of site navigation and information at the end of a page. This is the place where a user will look once they have finished scrolling through the current page or are looking for additional information about the website.
Flexbox is used to structure the html so that the footer is always on the bottom of the page. It is important to keep the structure of page within the three HTML5 tags <header>, <main> and <footer> as shown below.
< body >
< header ></ header >
< main ></ main >
< footer ></ footer >
</ body >
|
Example:
HTML
<!DOCTYPE html>
< html >
< head >
< title >
The Materialize Footer Example
</ title >
< meta name = "viewport" content =
"width=device-width, initial-scale=1" >
< link rel = "stylesheet" href =
< script src =
</ script >
</ head >
< body class = "container" >
< footer class = "page-footer green" >
< div class = "container " >
< div class = "row" >
< div class = "col l6 s12" >
< h5 class = "white-text" >
Footer Content
</ h5 >
< p class = "grey-text text-lighten-4" >
Rows and columns are
used to organize the footer content.
</ p >
</ div >
< div class = "col l4 offset-l2 s12" >
< h5 class = "white-text" >Links</ h5 >
< ul >
< li >
< a class = "grey-text text-lighten-3" href = "#!" >
Link 1
</ a >
</ li >
< li >
< a class = "grey-text text-lighten-3" href = "#!" >
Link 2
</ a >
</ li >
< li >
< a class = "grey-text text-lighten-3" href = "#!" >
Link 3
</ a >
</ li >
</ ul >
</ div >
</ div >
</ div >
< div class = "footer-copyright green darken-3" >
< div class = "container " >
© 2020 Copyright Text
< a class = "grey-text text-lighten-4 right" href = "#!" >
More Links
</ a >
</ div >
</ div >
</ footer >
</ body >
</ html >
|
Output:

Sticky Footer: A sticky footer always stays on the bottom of the page regardless of how little content is on the page. However, this footer will be pushed down if there is a lot of content, so it is different from a fixed footer. Add the following code to your CSS file.
body {
display: flex;
min-height: 100vh;
flex-direction: column;
}
main {
flex: 1 0 auto;
}
Example:
HTML
<!DOCTYPE html>
< html >
< head >
< title >
The Materialize Footer Example
</ title >
< meta name = "viewport" content =
"width=device-width, initial-scale=1" >
< link rel = "stylesheet" href =
< script src =
</ script >
< style >
/* Add CSS for making the
footer sticky */
body {
display: flex;
min-height: 100vh;
flex-direction: column;
}
main {
flex: 1 0 auto;
}
</ style >
</ head >
< body class = "container" >
< main >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< p >
A Computer Science portal for geeks.
</ p >
</ main >
< footer class = "page-footer green" >
< div class = "container " >
< div class = "row" >
< div class = "col l6 s12" >
< h5 class = "white-text" >
Footer Content
</ h5 >
< p class = "grey-text text-lighten-4" >
Rows and columns are
used to organize the footer content.
</ p >
</ div >
< div class = "col l4 offset-l2 s12" >
< h5 class = "white-text" >Links</ h5 >
< ul >
< li >
< a class="grey-text
text-lighten-3" href = "#!" >
Link 1
</ a >
</ li >
< li >
< a class="grey-text
text-lighten-3" href = "#!" >
Link 2
</ a >
</ li >
< li >
< a class="grey-text
text-lighten-3" href = "#!" >
Link 3
</ a >
</ li >
</ ul >
</ div >
</ div >
</ div >
< div class = "footer-copyright green darken-3" >
< div class = "container " >
© 2020 Copyright Text
< a class="grey-text
text-lighten-4 right" href = "#!" >
More Links
</ a >
</ div >
</ div >
</ footer >
</ body >
</ html >
|
Output:
