Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to anchor a DIV to the bottom of a page?

I have a fixed-width DIV that I want to remain at the bottom of the browser's viewport.

Unfortunately, I haven't a clue where I would even begin to try to implement this.

Obviously the first thing to do is set position to fixed. But beyond that... no clue.

like image 689
Nathan Osman Avatar asked Jun 04 '10 03:06

Nathan Osman


People also ask

How do I anchor a div to the bottom of the page?

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 I make a div extend to the bottom?

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.


2 Answers

See at css-tricks:

Fixed Footer

CSS:

#footer {    position:fixed;    left:0px;    bottom:0px;    height:30px;    width:100%;    background:#999; }  /* IE 6 */ * html #footer {    position:absolute;    top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px'); } 
like image 123
Sarfraz Avatar answered Sep 24 '22 11:09

Sarfraz


#mydiv{    position: fixed;    bottom: 0px; } 
like image 36
airportyh Avatar answered Sep 23 '22 11:09

airportyh