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

MySQL 8.0.15 version installation tutorial connect to Navicat.list

The pitfalls 1. Many tutorials on the Internet wr...

Quick understanding and example application of Vuex state machine

Table of contents 1. Quick understanding of conce...

How to create, save, and load Docker images

There are three ways to create an image: creating...

How to install MySQL 8.0 database on M1 chip (picture and text)

1. Download First of all, I would like to recomme...

View the dependent libraries of so or executable programs under linux

View the dependent libraries of so or executable ...

How to use stored procedures in MySQL to quickly generate 1 million records

Preface When testing, in order to test the projec...

Linux unlink function and how to delete files

1. unlink function For hard links, unlink is used...

A Brief Analysis of MySQL - MVCC

Version Chain In InnoDB engine tables, there are ...

Detailed installation tutorial of zabbix 4.04 (based on CentOS 7.6)

1. Preparation before installation: 1.1 Install J...

Example of converting timestamp to Date in MySQL

Preface I encountered a situation at work: In the...

Solution for Docker Swarm external verification load balancing not taking effect

Problem Description I created three virtual machi...

Dynamically add tables in HTML_PowerNode Java Academy

Without further ado, I will post the code for you...