Forum Moderators: not2easy

Message Too Old, No Replies

Flexible Fill in the Bottom Part of a Page.

Fixed top, flexible bottom.

         

cmarshall

10:37 am on May 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is another of those basic issues that is probably a "no-brainer," but here I am, once again searching for the best way to do this. I'm sure it can be done, but what I see out there is not exactly what I need.

I have a page with a narrow strip along the top, containing some links and whatnot (You can think of it as a "menu bar.")

The rest of the page needs to be completely filled with content. It's a Google Map, so I have to explicitly define a size (Google Maps will not define a size, they use whatever the container gives them).

It works perfectly if I do not have the menu strip, as I can do this:

<body style="width:100%;height:100%">
<div id="map" style="width:100%;height:100%;position:absolute"></div>
</div>

However, when I introduce the menu strip, things change:

<body style="width:100%;height:100%">
[red][b]<div id="menu" style="width:100%;height:1.5em"></div>[/b][/red]
<div id="map" style="width:100%;position:absolute;[red][b]height:?;top:1.5em[/b][/red]"></div>
</div>

This works perfectly in FF:

<body style="width:100%;height:100%">
<div id="menu" style="width:100%;height:1.5em"></div>
<div id="map" style="width:100%;position:absolute;[red][b]bottom:0;top:1.5em[/b][/red]"></div>
</div>

However (of course), not in IE.

Here's the kludge I use for cross-browser compliance:

<body style="width:100%;height:100%">
<div id="menu" style="width:100%;height:1.5em"></div>
<div id="map" style="width:100%;position:absolute;top:1.5em;[red][b]height:97%[/b][/red]"></div>
</div>

EEEWWW...

The idea is not to trigger scrollbars. I want the window to be completely flexible and to use as much of the space as possible. The kludge gives me 95% of this. The window has to be made pretty small to trigger scrollbars, but there is a tiny strip on the bottom for most sizes.

BTW: Frames are out, even though they would give me exactly what I want. I don't want to get into why, but I won't use them.

What is the simplest and most robust solution to this?

Robin_reala

12:30 pm on May 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you put a sleeve inside <div id="map">? You could then give that padding-top:1.5em and position the menu absolutely at the top of the page.

cmarshall

12:38 pm on May 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What timing!

I am actually trying to that right now, to no avail. I keep getting scrollbars, no matter what I do.

I need to do a bit of research, but I seem to remember that IE doesn't use the traditional "top, bottom, right, left" properties. It has something else.

What I want is the solution that works for FF. That is the cleanest and most effective.

If anyone is interested, I can SM the URI of the page that demonstrates the issue. It is jammed full of JavaScript, but hardly has any CSS or markup.

SuzyUK

6:20 pm on May 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what about simply Absolutely Positioning the menu bar on top of the image/map - I take it the map is draggable so the bit the 1.5em high menu bar would cover would still be reachable?

Xapti

7:13 pm on May 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use JS to have IE emulate the bottom attribute, because it doesn't support it, which is why it doesn't work for IE.

Best to put the JS in a conditional comment so no other browsers have to render it.

[edited by: Xapti at 7:18 pm (utc) on May 23, 2007]

cmarshall

10:30 am on May 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, there are JS ways to do it. Dabrowski actually has some pretty nice stuff that does this. I was hoping for a CSS way to deal with it.

I did figure out a less kludgy (but still kludgy) way to do it:

I hide the top 30 pixels of the map under the bar and offset the map controls. This is good, except that some windows show up under the bar. I was able to ameliorate that by forcing the map to pan the point of interest to the center. This makes most popups happen closer to the center. Not perfect, but it looks very "cool," and has been received well.

If people have not been using the Google Maps API [google.com], you may not know what you're missing. Google did their homework.