views:

200

answers:

3

Can anybody think of a non-Javascript way to do the following:

  • There is a DIV element somewhere on the screen. Its position can not be predicted.
  • It has a fixed width, and should overlap all the other content in the document, ie. it has "position" set to "absolute".
  • This is the catch: I want the bottom edge of the DIV to be glued to the bottom of the Viewport. I tried giving the element "bottom: 0px", but in absence of a "height" setting, the whole DIV moves down to the bottom corner, which is not what I want. I want it to stretch from the random position in the document to the bottom edge of the viewport.

I cannot see a solution without using JavaScript, but maybe somebody has a brilliant idea.

+1  A: 

I believe the following is not IE6 compatible, but works on all other browsers. With the bottom, you should also give it a top. Once you set the height, it will take precedence (I gave it a border so you can see it stretching):

<div style="position:absolute;top:150px;bottom:10px;width:100px;border:1px solid red;">
    I'm stretched to the  bottom
</div>
Abel
Thanks Abel, but what I am looking for is more tricky: I want to use the element's implicit start position, i.e. I do not want to give it a "top" property but start exactly where the browser put it. Just the bottom edge of the div should behave like a "fixed" element and always stick to the bottom of the screen. When I scroll the document, the DIV should stretch and shring accordingly. I'm starting to think this can only be done with JavaScript.
Pekka
Indeed, that's something you should do with JavaScript. I experimented with `expression(..)` (which is basically JavaScript in CSS and it is uuuugly) and that didn't give me much either. The bottom/top bug btw, is still around in IE7, only solved in IE8, but that wouldn't help here: you want to mix fixed and absolute.
Abel
All right, this is definitely going to need some Javascript. But not today, I so am not in the mood :) Still, thanks for the effort.
Pekka
A: 

try this

http://www.doxdesk.com/software/js/fixed.html

also try to check position:relative; position:static; position:fixed;

Thanks freeweb.pk

freeweb.pk
A: 

I guess this one is not solvable. I am accepting my own answer in this case.

Pekka