Well, I managed to solve it. Using option relativeTo for the offset and setting the relativeTo to use my header div that is always present, and always absolutely positioned at top:0;
Now I have a div that takes up whatever space is left down to bottom of viewport, just like I wanted. Thanks for all help! On 30 Sep, 10:18, Kabelkultur Gotland <[EMAIL PROTECTED]> wrote: > Well, thanks, but it turns out that it does exactly the same as my own > function. > If I have a div above it with a SET TOP position, e.g. css: top:0; - > or whatever - it works. > But if I don't have nothing but a bunch of <br/> tags above the div, > or if I set the div above to psition:relative and remove the set top > position, it doesn't work anymore. > I really need some way to get the top offset for my div from the top > edge of the window, no matter what may or may not be above the div in > the DOM tree, and so far no luck. > But thanks for the effort, I appreciate it. > > /Torgil > > On 29 Sep, 21:26, rolfsf <[EMAIL PROTECTED]> wrote: > > > > > try this: > > > var wh = $(window).height(); // window height > > var mt = $('#myDiv').offset().top; // top > > position of #myDiv > > > $(mt).css('height', wh - mt - 20 + 'px'); // set > > height of #myDiv > > > On Sep 29, 8:33 am, Kabelkultur Gotland <[EMAIL PROTECTED]> wrote: > > > > Well, the $(window).height() gets the height for me. > > > > What I need is something to measure the distance from the window top > > > and down to the element top. > > > And then subtract it from the window height, minus another 20 pix ad > > > use that value as height for the div. > > > > If the window is 1000 px high, and the div starts 300px down, I'd like > > > to get 100 - 300 - 20 = 680 > > > And then apply this as height for the div. > > > > And this needs to be done without mixing in other elements that might > > > or might not be part of the dom tree between the window top and the > > > elements top position. > > > > So I guess that the problem lies within the second measuring parameter > > > of my function: > > > $ (".tableHolder").offset().top - this for some reason uses other > > > positioned elements for its calculation, and I need it not to. > > > > Regards, Torgil - kabelkultur.se- Dölj citerad text - > > > - Visa citerad text -- Dölj citerad text - > > - Visa citerad text -