<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>使用CSS定位footer-www.aspxcs.net(.Net中文社区)</title> <style type="text/css"> body,html { margin: 0; padding: 0; font: 12px/1.5 arial; height:100%; } #container { position: relative; min-height:100%; } #content { padding: 10px; padding-bottom: 60px; /*(20px font-size x 2 line-height) + (2 * 10px padding) = 60px*/ } #footer { position: absolute; bottom: 0; padding: 10px 0; background-color: #AAA; width: 100%; } #footer h1 { font: 20px/2 Arial; margin:0; padding:0 10px; } </style> </head> <body> <div id="container"> <div id="content"> <h1>Content</h1> <p>请改变浏览器窗口的高度,以观察footer效果。</p> <p><a href="http://www.aspxcs.net/" _fcksavedurl="http://www.aspxcs.net/">.Net中文社区,为您提供最全面最实用的教程代码</a>请改变浏览器窗口的高度,以观察footer效果。.Net中文社区,为您提供最全面最实用的教程代码</p> <p><a href="http://www.aspxcs.net" _fcksavedurl="http://www.aspxcs.net">.Net中文社区,为您提供最全面最实用的教程代码</a>请改变浏览器窗口的高度,以观察footer效果。.Net中文社区,为您提供最全面最实用的教程代码</p> </div> <div id="footer"> <h1>Footer</h1> </div> </div> </body> </html>