【问题标题】:JQuery CSS Use a "height: auto;" as a "margin-bottom" for another element [closed]JQuery CSS 使用“height: auto;”作为另一个元素的“边距底部”[关闭]
【发布时间】:2014-02-24 04:23:24
【问题描述】:

我有一个高度设置为“自动”的页脚。现在,我希望站点容器的底部边距与页脚的高度相同(动态)。 怎么样?

HTML:

<div id="footer" class="arial">
    <p>
        Lorem ipsum
        <br>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    </p>            
</div>

CSS:

#footer {
    width:100%;
    height: auto;
    position:fixed;
    bottom: 0;
    background-color:#3498db;
    text-align: center;
    line-height: 23px;
    font-size: 15pt;    
}

【问题讨论】:

    标签: jquery html css dynamic footer


    【解决方案1】:
    $('#container').css('margin-bottom', $('#footer').height());
    

    显然,这应该只在页面加载后运行,否则它将具有所有错误的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-19
      • 2017-03-25
      • 1970-01-01
      • 2013-08-21
      • 1970-01-01
      • 2013-07-29
      相关资源
      最近更新 更多