views:

58

answers:

2

What I want:

   <div style="overflow:scroll;width:100%;height:50%;"> &nbsp;
    <div style="height:500px;width:400px;border:solid 3px red;">
        </div>
        </div>

<div style="overflow:scroll;width:100%;HEIGHT:50%;"> &nbsp;
    <div style="height:500px;width:400px;border:solid 3px red;">
        </div>
        </div>

Notice how if I shrink the height of the window the scrollbars shrink. This is the functionality I want.

The issue:
I want to make something similar to the above, only with a fixed height of 100 pixels for the top div.

If I do this in practice the bottom scrollbar no longer shrinks as I shrink the page - the system adds an outer scrollbar to manage both sections. I don't want this, I want to retain the behavior seen above.

How do I do this?

A: 

I'm not entirely sure whether I understand you correctly, but it looks to me like you are trying to combine relative and pixel values, which never works.

this is the only way I can see to do this. It positions the elements absolutely.

  <div style="position: absolute; 
              left: 0px; top: 0px; height: 100px; 
              overflow:scroll;right: 0px;">
    &nbsp;
    <div style="height:500px;width:400px;border:solid 3px red;">
        </div>
        </div>

<div style="position: absolute; 
            left: 0px; top: 100px; 
            bottom: 0px; right: 0px; 
            overflow:scroll;"> 
    &nbsp;
    <div style="height:500px;width:400px;border:solid 3px red;">
        </div>
        </div>
Pekka
This creates an extra outer scrollbar.In my first example, the scrollbars expand and shrink as the window shrinks.This is done because they are percentages and not fixed widths.What I want to do is keep the behavior when the window height shrinks, but have a max height for the top div when the window height expands.In your example if the window height shrinks too much a new third scrollbar appears. The users complained that they have multiple vertical scrollbars to contend with, and this is is precisely what I'm trying to avoid.
diadem
@diadem I see. I'm not sure this is possible. What you could try is using a table width 100% width and height, two rows and a cell in each, the top cell having a `max-height: 100px` attribute.
Pekka
@diadem you can always get rid of the additional scrollbar using `overflow: hidden` on the `body` btw if that is usable in your case (it often does not.)
Pekka
@Pekka: turning off the ability to scroll would just cause them to lose functionality. The scrollbars would not expand and contract like they do in the working example. They would remain static as the user shrinks the screen. This would crop the bottom of the screen.
diadem
A: 

I found the answer. I need to use css expressions

       <div style="overflow:scroll;width:100%;height:100px"> &nbsp;
    <div style="height:500px;width:400px;border:solid 3px red;">
        </div>
        </div>

<div style="overflow:scroll;width:100%;height:expression((document.body.clientHeight - 120) + 'px');"> &nbsp;
    <div style="height:500px;width:400px;border:solid 3px red;">
        </div>
        </div>
diadem