473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Creating variable height 2nd box with CSS in IE and Mozilla.

Okay,

What I'm trying to do is create two boxes, one on top of the other.
The first is a static height, the 2nd, underneath it, should take up
the remaining amount of screen space and overflow with its own
vertical scrollbar for any extra content.

I've managed to come up with this, which works perfectly in Mozilla,
but fails in IE:

<body style="width: 99%; height: 98%">
<div style="position: absolute; top: 0px; left: 0px; width: 100px;
height: 50px; border: solid green 1px">
Top box.
</div>
<div style="position: absolute; top: 100px; bottom: 0px; width: 100px;
border: solid blue 1px; overflow: auto">
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>Bottom box.<p>
</div>
</body>

(Note: I'm setting the width and height of "body" to 99% and 98%
respectively so that I don't get scrollbars for the browser window
itself.)

In IE, the 2nd DIV's "bottom: 0px" declaration is completely ignored
and I end up with a browser window vertical scrollbar as the DIV
overflow doesn't take effect.

It took me a long time to come up with the (now) intuitive method of
setting the top and bottom properties of the 2nd box - when it worked
(in Mozilla) I was overjoyed. But that quickly disappeared when I
realised that IE messed it up.

I'm assuming here that Mozilla is properly applying the standards, and
IE is not. How can I work around this? (Javascript is not acceptable.)

Note that my main problem here is that I can't use "height: 100%" on
the 2nd DIV because then it will extend below the bottom of the
browser window. Nor can I determine either a percentage or pixel
height that will scale to fit a variable screen height. (This could be
solved if I could use something like "height: 100% - 100px" - but that
kind of calculation isn't valid.)

An alternative way of looking at this problem is - how do I do the
equivalent in CSS:

<frameset rows="50,*">
<frame src="page1.html">
<frame src="page2.html">
</frameset>

I did come up with a total hack, but it's problematic at best:

Have both DIVs start at the top of the page, one can be "50px", the
other "100%", but have the 1st DIV with a higher z-index, and the 2nd
DIV with an embedded 3rd DIV that uses "margin-top: 50px".

The problem with this, however (in addition to just being totally
wrong), is that the vertical scrollbar of the 2nd DIV ends up
extending all the way to the top of the browser window and interfering
with elements of the 1st DIV...

Does anybody have any ideas here?
Jul 20 '05 #1
6 3395
> (Note: I'm setting the width and height of "body" to 99% and 98%
respectively so that I don't get scrollbars for the browser window
itself.)


And being a complete idiot. It should be:

<body style="margin: 0px; padding: 0px; width: 100%; height: 100%">

Anything else is has problems.
Jul 20 '05 #2
> (Note: I'm setting the width and height of "body" to 99% and 98%
respectively so that I don't get scrollbars for the browser window
itself.)


And being a complete idiot. It should be:

<body style="margin: 0px; padding: 0px; width: 100%; height: 100%">

Anything else is has problems.
Jul 20 '05 #3
> (Note: I'm setting the width and height of "body" to 99% and 98%
respectively so that I don't get scrollbars for the browser window
itself.)


And being a complete idiot. It should be:

<body style="margin: 0px; padding: 0px; width: 100%; height: 100%">

Anything else has has problems.
Jul 20 '05 #4
> (Note: I'm setting the width and height of "body" to 99% and 98%
respectively so that I don't get scrollbars for the browser window
itself.)


And being a complete idiot. It should be:

<body style="margin: 0px; padding: 0px; width: 100%; height: 100%">

Anything else has has problems.
Jul 20 '05 #5
Some days I just shouldn't get out of bed. <sigh>

My apologies for the double post.
Jul 20 '05 #6
Some days I just shouldn't get out of bed. <sigh>

My apologies for the double post.
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andy R. | last post by:
Hello everyone, I've spent quite some time now, looking for some information on how to get this done, sadly none has helped me much, though. I have a bit of java scrpt on a webpage (.php) to...
22
by: Tom Moroow | last post by:
Hi, I'm pretty new to javascript and was wondering how you would piece together a variable name and then assign it a value. I want to create a hidden field and assign it a value based on the value...
14
by: delerious | last post by:
I need to determine an element's width and height in pixels (not including padding, border, and margin) in Javascript. The element will not have width or height styles specified. In Mozilla, I...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
4
by: Howard Jess | last post by:
In a javascript-heavy page, an iframe is created to hold information from a secondary server CGI process, and the resulting data (in the iframe) is used to rewrite some content in the main page. To...
1
by: shmodi | last post by:
Hi All, I am new here and want to get some help for speeding up and resolving IE issue while creating tree using ajax. My tree contains radio buttons at each level and I am getting all tree...
1
by: since | last post by:
How do I get a html table in mozilla to only have scrollbars if it is exceeds a height. "max-height" used to work but it no longer works for me. I can scrollbars added if it exceeds a height. In the...
8
by: BillE | last post by:
When I create a control dynamically and it grows according to the content, the control Height property still returns the original default control height instead of the height after expanding. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.