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

本文共 1346 字,大约阅读时间需要 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.

转载地址:http://nhxao.baihongyu.com/

你可能感兴趣的文章
rabbitMQ消息队列原理
查看>>
Nagios之安装篇
查看>>
平衡二叉树中第k小的数 Kth Smallest Element in a BST
查看>>
我的友情链接
查看>>
Vyos防火墙功能配置
查看>>
Redhat内核编译
查看>>
Hyper-V 2016 系列教程4 Hyper-V 虚拟机的新建
查看>>
Flask开发
查看>>
trickle 限制用户空间带宽
查看>>
SQL事务
查看>>
GRE配置案例实现远程网络通信
查看>>
不用linux作为桌面的N个理由
查看>>
Rabbitmq学习之路3-cluster
查看>>
iptables实现NAT(网络搜索整理)
查看>>
关于ip地址
查看>>
ASP.NET自定义404和500错误页面
查看>>
OpenGL学习(七)纹理映射
查看>>
一些必不可少的Sublime Text 2插件
查看>>
测试项目
查看>>
第一章ASP.NET SignalR简介
查看>>