A simple way to put HTML footer at the bottom of the page

A simple way to put HTML footer at the bottom of the page

Requirement: Sometimes, when the page content is short and cannot support the browser height, but you want the footer to be at the bottom of the window.

Idea: The minimum height of the footer's parent layer is 100%. The footer is set to be absolutely (absolute) bottom (bottom: 0) relative to the parent layer, and the height of the footer must be reserved in the parent layer.

HTML code:

XML/HTML CodeCopy content to clipboard
  1. <!-- Parent layer -->      
  2. < div   id = "wapper" >      
  3.      <!-- Main content -->      
  4.      < div   id = "main-content" >      
  5.      </ div >      
  6.      <!-- Footer -->      
  7.      < div   id = "footer" >      
  8.      </ div >      
  9. </ div >      

The CSS is as follows:

CSS CodeCopy content to clipboard
  1. #wapper {
  2.      position : relative ; /*Important! Ensure that the footer is absolutely relative to the wapper position */      
  3.      height : auto ; /* Ensure that the page can be displayed normally when the browser height is expanded*/      
  4.      min-height : 100% /* IE6 does not support it, IE6 needs to be configured separately*/      
  5. }
  6. #footer {
  7.     position : absolute ; bottom : 0; /* Key */      
  8.     left :0; /* Be sure to remember this in IE */      
  9.     height : 60px ; /* The height of the footer must be a fixed value*/      
  10. }
  11. #main - content {
  12.     padding-bottom : 60px ; /*Important! Space reserved for footer*/      
  13. }

At this point, other browsers can display it normally, but IE 6 needs to handle it separately:

CSS CodeCopy content to clipboard
  1. <!--[if IE 6]->
  2. <style>
  3. #wapper { height :100%;} /* IE will automatically expand the layer when the height is not enough*/      
  4. </style>
  5. <![endif]-->

The above simple implementation method of placing the HTML footer at the bottom of the page is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

<<:  The new version of Chrome browser settings allows cross-domain implementation

>>:  Detailed explanation of the core concepts and basic usage of Vuex

Recommend

CentOS7 64-bit installation mysql graphic tutorial

Prerequisites for installing MySQL: Install CentO...

Analysis of the difference between emits and attrs in Vue3

Table of contents in conclusion Practice Analysis...

A brief introduction to the simple use of CentOS7 firewall and open ports

Overview (official has more detailed description)...

Mysql anonymous login cannot create a database problem solution

Frequently asked questions Access denied for user...

Commonly used js function methods in the front end

Table of contents 1. Email 2. Mobile phone number...

Implementation of Nginx forwarding matching rules

1. Regular expression matching ~ for case-sensiti...

Gearman + MySQL to achieve persistence operation example

This article uses the gearman+mysql method to imp...

Vue realizes screen adaptation of large screen pages

This article shares the specific code of Vue to a...

Detailed explanation of Docker daemon security configuration items

Table of contents 1. Test environment 1.1 Install...

Native js implements a minesweeper game with custom difficulty

This article example shares the specific code of ...

Vue+Echart bar chart realizes epidemic data statistics

Table of contents 1. First install echarts in the...