相对改变DIV高度

时间:2013-11-19 16:21:28

标签: jquery position html

我正在为footer <div>使用sticky footer方法,看起来更好我希望调整侧边栏的大小以适应页眉和页脚之间。像这条绿线: enter image description here

我在stickyFooter函数中使用了这行代码,但不起作用:

$("#sidebar").height($(window).height() - $(footer).height() - 
$("#header").height());

是什么让我告诉它不起作用?它滚动到无限!你可以在这里看到:http://jsfiddle.net/maysamsh/sxcmr/embedded/result/

在这里,您可以找到所有内容:http://jsfiddle.net/maysamsh/sxcmr/

最后一件事,我不想使用相同高度列的其他方法。

2 个答案:

答案 0 :(得分:0)

删除window.onresize() 对代码http://jsfiddle.net/sxcmr/1/show/

进行了一些更改

不要在调整大小或加载时调用插件,只需使用

即可
$("#footer").stickyFooter();

答案 1 :(得分:0)

此解决方案适用于我(不需要jQuery):

HTML code:

<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<div class="wrapper">

site body here ("push" must be empty)

<div class="push"></div>
</div><!-- wrapper end -->

<div class="footer_cont">
    <div class="footer">
        your footer here...
    </div>
</div>
</body>
</html>

CSS:

html { height:100%; }
body { height:100%; }

.wrapper {
min-height:100%;
height:auto !important;
height:100%;    
margin:0 auto 64px; }

.push { height: 64px; }
.footer_cont { height:64px; }
.footer { margin:0px auto; width:960px; }

正如您所见,页脚高64px,宽960。