Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lock element to bottom of containing div [duplicate]

Tags:

html

css

#Container {     width: 500px;     height: 600px; }  #TheElement {     width: 500px;     height: 100px;     background-color: #000000; } 

How do i get #TheElement to be locked to the very bottom of #Container, regardless of the other content inside container, without a bunch of margin trickery?

like image 305
WillingLearner Avatar asked Feb 27 '11 21:02

WillingLearner


People also ask

How do I keep an element at the bottom of a div?

Set the position of div at the bottom of its container can be done using bottom, and position property. Set position value to absolute and bottom value to zero to placed a div at the bottom of container.

How do you anchor an element to the bottom?

Just set the parent div with position:relative . Then, the inner item you want to stick to the bottom, just use position:absolute to stick it to the bottom of the item.

How do you make an input stick to the bottom of a div?

Add position: absolute; and bottom: 0; to those . test cubes (you could also add left: 0 , but that's the default anyway), and position: relative; to their containers to have them serve as an "anchor" for the absolute position of their children. Tnx for your answer.

How do I fix the bottom element in html?

If position: absolute; or position: fixed; - the bottom property sets the bottom edge of an element to a unit above/below the bottom edge of its nearest positioned ancestor. If position: relative; - the bottom property makes the element's bottom edge to move above/below its normal position.


1 Answers

You can use relative absolute positioning:

http://jsfiddle.net/gzJM6/

#Container {     width: 500px;     height: 600px;     position: relative }  #TheElement {     width: 500px;     height: 100px;     background-color: #000000;     position: absolute;     bottom: 0;     left: 0; } 
like image 178
thirtydot Avatar answered Oct 02 '22 19:10

thirtydot