


This article will introduce to you how to use css to achieve the effect that the page content is not high enough and the footer is always at the bottom of the page. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
I believe that many front-end engineers will encounter this situation when developing pages: When the height of the entire page is not enough to occupy one screen of the display screen, and the footer is not at the bottom of the page, it will be a bit unsightly for the user. I think To keep the footer always at the bottom of the page, we may think of using:
1.min-height to control the height of the middle content area so that the height of the page can fill up one screen of the display. However, large website pages are relatively In many cases, the footer is added modularly, and the height of each page is different. It is impossible to set the min-height of the content area in the middle of each page, and the size of the user's display screen is different, so it is impossible to be precise. Setting the min-height height cannot guarantee that the user will see that the footer of the page is not at the bottom or that the scroll bar does not appear on the page;
2. Fixed positioning of the footer: The footer will be displayed at the bottom relative to the fixed positioning of the body. , but when the page has a scroll bar and the page scrolls, the footer will be suspended above the content area. Maybe none of the above is the effect you want.
You can use the following example method to solve your problem:
nbsp;html> <meta> <title>猿来是勇者</title> <!--方法一--> <style> *{margin: 0; padding: 0;} html,body{height:100%;} #container{position:relative; width:100%; min-height:100%;padding-bottom: 100px; box-sizing: border-box;} header{width: 100%; height: 200px; background: #999;} .main{width: 100%; height: 200px; background: orange;float:left;} footer{width: 100%; height:100px; /* footer的高度一定要是固定值*/ position:absolute; bottom:0px; left:0px; background: #333;} </style> <p> <header>HEADER</header> <section>MAIN</section> > <footer>FOOTER</footer> </p> <!--方法二--> <!--<style> *{margin: 0; padding: 0;} html,body{height: 100%;} #container{display: flex; flex-direction: column; height: 100%;} header{background: #999; flex: 0 0 auto;height:100px;} .main{flex: 1 0 auto;} .bg{background:orange;height:200px;} footer{background: #333; flex: 0 0 auto;height:100px;} </style> <body> <p id="container"> <header>HEADER</header> <section class="main"> <p class="bg">MAIN</p> </section> <footer>FOOTER</footer> </p> </body>-->
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's learning. For more related tutorials, please visit CSS Video Tutorial!
The above is the detailed content of css achieves the effect that the page content is not high enough and the footer is always at the bottom of the page. For more information, please follow other related articles on the PHP Chinese website!

If you've ever had to display an interactive animation during a live talk or a class, then you may know that it's not always easy to interact with your slides

With Astro, we can generate most of our site during our build, but have a small bit of server-side code that can handle search functionality using something like Fuse.js. In this demo, we’ll use Fuse to search through a set of personal “bookmarks” th

I wanted to implement a notification message in one of my projects, similar to what you’d see in Google Docs while a document is saving. In other words, a

Some months ago I was on Hacker News (as one does) and I ran across a (now deleted) article about not using if statements. If you’re new to this idea (like I

Since the early days of science fiction, we have fantasized about machines that talk to us. Today it is commonplace. Even so, the technology for making

I remember when Gutenberg was released into core, because I was at WordCamp US that day. A number of months have gone by now, so I imagine more and more of us

The idea behind most of web applications is to fetch data from the database and present it to the user in the best possible way. When we deal with data there

Let's do a little step-by-step of a situation where you can't quite do what seems to make sense, but you can still get it done with CSS trickery. In this


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software