Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

align an element to the bottom of window

Tags:

css

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>
like image 845
Xavier Avatar asked May 17 '11 09:05

Xavier


People also ask

How do you move an element to the bottom in CSS?

To put an element at the bottom of its container with CSS, you need to use the following properties and values: position: relative; (parent) position: absolute; (child) bottom: 0; (child)

How do you align an element at the bottom of a div?

Use the text-align property to align the inner content of the block element. Use the bottom and left properties. The bottom property specifies the bottom position of an element along with the position property. The left property specifies the left position of an element along with the position property.

How do you make an element extend to the bottom of page?

If you need to make a <div> element extend to the bottom and fill the page, try the following. Use viewport units and set the height and width of the <body> element to “100vh” and “100vw” respectively. Both the margin and padding of the <html> and <body> elements must be set to 0.


1 Answers

Further to my question on your OP, this can be done in CSS:

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

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.

like image 143
Rory McCrossan Avatar answered Oct 13 '22 21:10

Rory McCrossan