将元素对齐到窗口的底部 [英] align an element to the bottom of window

查看:110
本文介绍了将元素对齐到窗口的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用jquery计算窗口高度,然后应用该值到一个DIV(容器div)最终我想让jquery对齐一个元素到页面的底部。

I am trying to use jquery to calculate the window height then apply that value to a DIV (the container div) finally i want the jquery to align an element to the bottom of the page.

    <div id="wrapper">
        <div id="element-align">Here is the element i wish to align to the bottom</div>
    </div>


推荐答案

在CSS中完成:

#element-align {
    position: fixed;
    bottom: 0;
}

如果需要,您还可以向元素添加左/固定定位将意味着元素将总是出现在相对于浏览器chrome的相同位置,而不管页面的滚动位置。

If needs be you can also add left/right to the element, but the fixed positioning will mean that the element will always appear in the same place relative to the browser chrome, regardless of the scroll position of the page.

这篇关于将元素对齐到窗口的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆