【问题标题】:Calculate element height and apply to other element计算元素高度并应用于其他元素
【发布时间】:2011-12-06 02:03:30
【问题描述】:

使用“粘性页脚”,我需要让内容 div 的底部填充等于页脚高度。

我想使用 jQuery 来获取页脚高度并将该值应用于内容 div 底部填充值。

希望这是有道理的!

谢谢

【问题讨论】:

  • 是什么阻止你编写代码?
  • 那条评论不是很有建设性吗?我尝试过但失败了......
  • 然后提供代码,我们可以指出你哪里出错了。 StackOverflow 是一个寻求帮助的地方,而不是一个让你在懒得自己动手的时候找人免费编写代码的地方。

标签: jquery padding sticky-footer


【解决方案1】:
var height = $('#footer').height();
$('#content').css('padding-bottom',height+'px');

我认为这是解决您问题的方法

【讨论】:

  • 太棒了!我其实离我不远了……只是把它串起来的一个例子——谢谢!
【解决方案2】:
var height = $('#footer').height();

$('.other').css('paddingBottom', height);

【讨论】:

    【解决方案3】:

    你能粘贴一些代码吗? :)

    <script type="text/javascript">
    $(document).ready(function() {
    
        var footerheight = $('#footer').height();
        $('#contentarea').css('padding-bottom',footerheight+'px');
    
    });
    </script>
    

    【讨论】:

      猜你喜欢
      • 2019-07-16
      • 2013-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多