博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
最小高度设置
阅读量:5057 次
发布时间:2019-06-12

本文共 1414 字,大约阅读时间需要 4 分钟。

Below is the CSS code that makes your sticky footers actually stick to the bottom.

html, body {height: 100%;}#wrap {min-height: 100%;}#main {overflow:auto;	padding-bottom: 150px;}  /* must be same height as the footer */#footer {position: relative;	margin-top: -150px; /* negative value of footer height */	height: 150px;	clear:both;} /*Opera Fix*/body:before {	content:"";	height:100%;	float:left;	width:0;	margin-top:-32767px;/}

And on your html page you will need this conditional style for IE6 and earlier and for IE8 (!IE7 means not 7, but all others);

You'll notice that the footer height is used three times. This is important and should be the same value for all three instances. The height properties are stretching the wrap <div> to the full height of the window. The negative margin of the footer brings it up into the padding created for the main <div>. Since the main rests inside the wrap the padding height is already part of the 100%. Thus the footer rests at the bottom of the page.

The conditional statement is neccessary to allow IE8 to expand beyond the 100% height should the content be longer. The other hack is for browsers that dont understand min-height, in particular Opera. It uses a 100% height float to resize pages properly when adjusting the viewport (browser window) size. The -32767px margin is Opera's limit.

转载于:https://www.cnblogs.com/aimyfly/archive/2012/05/19/2508881.html

你可能感兴趣的文章
【AS3代码】播放FLV视频流的三步骤!
查看>>
枚举的使用
查看>>
luogu4849 寻找宝藏 (cdq分治+dp)
查看>>
日志框架--(一)基础篇
查看>>
关于源程序到可运行程序的过程
查看>>
转载:mysql数据库密码忘记找回方法
查看>>
scratch少儿编程第一季——06、人在江湖混,没有背景怎么行。
查看>>
【贪心+DFS】D. Field expansion
查看>>
C# Async与Await的使用
查看>>
Mysql性能调优
查看>>
iOS基础-UIKit框架-多控制器管理-实例:qq界面框架
查看>>
IOS-每个程序员的编程之路上都应该看这11本书
查看>>
自定义tabbar(纯代码)
查看>>
小程序底部导航栏
查看>>
ibatis学习笔记
查看>>
18-ES6(1)
查看>>
poj1611 简单并查集
查看>>
Ubuntu 14.04下安装CUDA8.0
查看>>
跨平台开发 -- C# 使用 C/C++ 生成的动态链接库
查看>>
C# BS消息推送 SignalR介绍(一)
查看>>