首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >fluid布局中底部的页脚

fluid布局中底部的页脚
EN

Stack Overflow用户
提问于 2012-03-10 07:42:16
回答 4查看 2.2K关注 0票数 9

我有一个流畅的布局,但结果是,当页面中没有足够的内容时,我的页脚会像在this example中一样向上移动。

将页脚保留在页面底部的一个流行的解决方案是使用position: fixedposition: absolute,然而,当我这样做时,内容可能会在调整大小时与页脚发生冲突(你可以看到我所说的here。尝试将窗口大小调整到文本隐藏在页脚后面的位置)。

那么,如何才能在页面底部设置页脚,并在流畅的布局中与页面的其余部分一起移动呢?

谢谢!

EN

Stack Overflow用户

发布于 2012-03-10 13:25:47

我可能会做这样的事...再加上一点jQuery。

代码语言:javascript
复制
var a = $('#floatdiv').height(); //get the height of the content
var b = $(window).height();      //get the height of the window
var c = $('footer').height();    //get the height of the footer
var d = b - c;                   //subtract the footer height from window height

if(a < b){                       //if the content is smaller than the window 
    $('#floatdiv').css('height', d + 'px');  //set the content height to the    
}                                            //window minus the footer

示例: http://jsfiddle.net/tM445/6/

票数 0
EN
查看全部 4 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9642460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档