CSS Sticky Footer: Perfect CSS absolute bottom_html/css_WEB-ITnose
Jun 24, 2016 pm 12:01 PM
The following is a relatively perfect method I found. A design expert from abroad uses pure CSS to achieve this: When the text content is small, the bottom is at the bottom of the window. There will be no overlapping issues when changing window height.
<div id="wrap"> <div id="main" class="clearfix"> <div id="content"> </div> <div id="side"> </div> </div></div><div id="footer"></div>
Note : The prerequisite for using this layout is that the footer must be outside the total div container. The footer uses a layer and all other content uses a layer. Total layer. If you really need to add other sibling layers, then this sibling layer must use position:absolute for absolute positioning.
CSS code:
The following is the main CSS code so that your bottom can be at the bottom of the window:
html, body, #wrap {height: 100%;}body > #wrap {height: auto; min-height: 100%;}#main {padding-bottom: 150px;} /* 必須使用和footer相同的高度 */#footer {position: relative; margin-top: -150px; /* footer高度的負值 */ height: 150px; clear:both;}
Note: What needs to be noted is that the padding value of #main, the height of footer and the negative margin value need to be consistent.
It’s that simple, but it’s not over yet. If your main body uses a floating layout, you have to solve some browser compatibility issues. The focus here is on Google Chrome.
Perform the famous Clearfix Hack on the #main part:
.clearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}.clearfix {display: inline-block;}/* Hides from IE-mac \*/* html .clearfix { height: 1%;}.clearfix {display: block;}/* End hide from IE-mac */
Note: This solution was tested on a two-column floating layout and is compatible All major browsers, including Google Chrome.
Reprinted from: http://paranimage.com/css-sticky-footer/

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The reason we use semantic tags is that they improve SEO, enhance accessibility, and code maintainability. 1. Include titles when using them to avoid abuse. 2. Use stand-alone content blocks, suitable for blogs or news. 3. Pay attention to the nesting and SEO of tags, and do not pile up tags for SEO.

There are five ways to include CSS in React: 1. Use inline styles, which are simple but not conducive to reuse and maintenance; 2. Use CSS files, which are implemented through import, which are conducive to organization but may lead to conflicts; 3. Use CSSModules to avoid global conflicts but require configuration; 4. Use StyledComponents to dynamically generate styles using JavaScript but require dependency on libraries; 5. Use Sass or Less to provide more functions but increase construction complexity.

There are three ways to selectively include CSS on a specific page: 1. Inline CSS, suitable for pages that are not frequently accessed or require unique styles; 2. Load external CSS files using JavaScript conditions, suitable for situations where flexibility is required; 3. Containment on the server side, suitable for scenarios using server-side languages. This approach can optimize website performance and maintainability, but requires balance of modularity and performance.

ThedifferentmethodsforincludingCSSinawebpageareinline,internal,andexternalCSS.1)InlineCSS:Easytoimplementbutleadstounmaintainablecode.2)InternalCSS:MoreorganizedthaninlinebutcanclutterHTML.3)ExternalCSS:Bestforlargerprojects,promotesmaintainabilityan

HTML, CSS and JavaScript are responsible for structure, style and dynamic functions in web development respectively. 1. HTML defines the web structure, 2. CSS is responsible for style and layout, 3. JavaScript provides dynamic interaction and functions.

ThebestpracticesforincludingCSSinawebsiteare:1)UseexternalCSSforseparationofcontentandpresentation,reusability,andcachingbenefits.2)ConsiderusingCSSpreprocessorslikeSassorLessformodularity.3)OptimizeperformancewithCSSminificationandcompression.4)Stru

CSSismostlycase-insensitive,butselectorsandcustompropertiesarecase-sensitive.1)Useconsistentcasingconventions.2)EmploylinterslikeStylelint.3)Testacrossbrowsers.4)Bemindfulofexternalresources'conventions.Consistentcasinghelpsmaintaincodecleanlinessand

The overflow attribute handles overflow content by hiding, scrolling or automatically adjusting. The main values ??include 1. Hidden direct cropping; 2. Scroll always displays scroll bars; 3. Auto displays scroll bars as needed; 4. Overflow-x and overflow-y can control horizontal and vertical overflow respectively. 1. overflow:hidden is used to avoid overflow of content; 2. overflow:scroll is suitable for chat windows or fixed-size sidebars to keep the interface consistent; 3. overflow:auto is suitable for tables or user-generated content to achieve flexible scrolling; 4. Note when setting overflow-x and overflow-y independently
