views:

35

answers:

3

How can I create a DIV block that always stays at the bottom of my page? When scrolling more content should show up right above the block. The only solution i can think of is to use 2 iframes but I prefer using CSS.

Update: The solution needs to work on iOS

+1  A: 
div.bottom {
  position:fixed;
}

Then just move it where you want. Unfortunately, browser support is limited. IE6 for example doesn't support this option for position. Also note that this removes the div from the flow, so you'll have to make sure there's enough space for the viewer to see stuff at the bottom of the page with the div on top.

Michael Mior
I don't know the screen size, how can I make it stay at the bottom?
Taho
+1  A: 

Here's some CSS:

.bottomFixed {
    position:fixed;
    bottom: 0;
    /* technically not necessary, but helps to see */
    background-color: yellow;
    padding: 10px;
}

Here's some HTML:

<div class="bottomFixed">Hello, world!</div>

This div would be placed at the bottom of the screen and stay there. Note: this won't work on iOS because of the way it does scrolling.

ahawtho
is bottom:0 the bottom of the current screen or bottom of the page? I need it to show at the bottom of the current screen
Taho
Bottom of the screen for position:fixed
ahawtho
Can i tweak it to make it work on iOS?
Taho
Just saw the update about iOS - on iOS, it's still the bottom of the "screen", but the display is just a viewport over the window's client area, so position: fixed doesn't work there. From what I've read, this is not possible on iOS.
ahawtho
A: 

See http://stackoverflow.com/questions/971123/css-fixed-to-bottom-and-centered

(why can't I post this as a comment? does stackoverflow have limitations to that?)

giorgiga
check http://stackoverflow.com/faq you only can comment when you have 50 rep points, which should be soon : )
aularon