2605/090
CSS-Two “Sticky Footer” Pure-CSS Solutions
如题,今天讲的是固底DIV的纯CSS解决方案,啊,或者说解决方法比较合适?
找了下资料,目前有2个比较可靠而且兼容性较好的解决方案,一个是CSS Sticky Footer,因为有中文版,大家自己看吧。
第2个是Ryanfait的《Make the Footer Stick to the Bottom of a Page》。
两者相差不大,最多就是CSS Sticky Footer少了一个DIV,且兼容的浏览器更多。
来,看一下《Make the Footer Stick to the Bottom of a Page》 的HTML代码:
<div class="wrapper"> <p>Your website content here.</p> <div class="push"></div> </div> <div class="footer"> <p>Copyright (c) 2008</p> </div>
这里的DIV->push就是多出来的那个DIV~引用CSS Sticky Footer的话说就是:
Some HTML purists may find this a blasphemous use of non-semantic code. Our solution avoids the extra
对照的中文翻译是:
对HTML语义要求严格的人可以说代码这么写是不符合规范的,我们的方案不用附加的DIV~
然后是CSS:
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -4em;
}
.footer, .push {
height: 4em;
}
这里同CSS Sticky Footer的做法是一样的,需要给.footer写一个height,并且在.wapper里写margin-bottom,height。
本人没有安装太多的浏览器测试,不过CSS Sticky Footer是号称兼容N多个浏览器,而Ryanfait的则是标了FF,IE,Opera,Safari。
Some Related Posts
- 2009/06/18 -- Flash-Transparent时在FF和Safari下无法输入中文的解决方案 (0)
- 2009/11/25 -- 记得关注你的竞争对手 (0)
- 2009/08/06 -- IE6 No More (2)
- 2008/12/15 -- IE6的absolute Bug (0)
- 2008/06/23 -- 关于HTML注释在IE,FF下的问题 (0)
- 2009/04/20 -- CSS Tools-Reset CSS (0)
- 2009/04/09 -- CSS Naked Day! (2)
- 2009/04/01 -- Flash-CSS,StyleSheet (0)
- 2008/08/06 -- Drupal模板页node.tpl.php/样式定制 (0)
- 2008/08/05 -- Drupal 模块webform介绍及建议 (0)
Tag: CSS, FF, Firefox, Html, IE, Opera, Safari, Sticky Footer
Leave a comment
Categories
- AIR+FB+AS3 (157)
- Android (22)
- Demo (71)
- fDEV (3)
- Flash AS2 (65)
- Game (17)
- jQuery (14)
- Others (93)
- PHP (42)
- Wordpress (60)
Recent Comments
- DFdou says under AS3-Caurina 动画类import caurina.transitions.Tweener; import caurin...
- DFdou says under Android-Permission V1.0:jrjr
- DFdou says under AS3-Captcha验证码类@太阴真人, HI,可以提供下具体是第几行报的错么
- 太阴真人 says under AS3-Captcha验证码类1084: 语法错误: rightparen 应在 semicolon 之前。 1084: 语法...
- DFdou says under Air-fWeather Google Weather Api使用例子@soluo, 是这个没错,这个数据的确是乱七八糟的,不是很准确~
- soluo says under Air-fWeather Google Weather Api使用例子博主,您好,请教您一个Google Weather Api的问题: 我用Google Weather...
- Anonymous says under Android-ListView用法:dahan
- DFdou says under Android-一些常用技巧手动调用MEDIA_SCANNER: Intent intent = new Intent(Inte...
- DFdou says under Flex – MXML组件开发@冬瓜, :dahan
- 冬瓜 says under Flex – MXML组件开发豆腐啊 你写的东西都好技术啊! :wc
Blogroll
Archive
- March 2010 (4)
- February 2010 (13)
- January 2010 (9)
- December 2009 (19)
- November 2009 (23)
- October 2009 (17)
- September 2009 (22)
- August 2009 (13)
- July 2009 (20)
- June 2009 (18)
- May 2009 (18)
- April 2009 (29)
- March 2009 (31)
- February 2009 (46)
- January 2009 (37)
- December 2008 (16)
- November 2008 (12)
- October 2008 (21)
- September 2008 (10)
- August 2008 (12)
- July 2008 (14)
- June 2008 (8)
- May 2008 (11)