473,385 Members | 1,317 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,385 software developers and data experts.

Allocate "rest" of height to a div?

I have this:

<div style="width:100%;height:20px">
bla
</div>
<div style="width:100%;height:???;overflow:scroll">
something
very
tall
so
that
it
produces
a
scrollbar
</div>
<div style="width:100%;height:50px">
another stuff
</div>

The three question marks indicate what I want to put there. What I
want to say is "window height minus 20px minus 50px", but I don't know
how to say it.

My current workaround is to put some JavaScript before </body> which
calculates the height of the window in pixels, subtracts 75 from this
number (75 = 20 + 50 + fudge factor), then frobs the DOM of the
document to say "width:4711px" instead of "width:???".

The problem with this workaround is that the corresponding div doesn't
resize when the user resizes the window: while the divs get narrower
or wider properly when the user resizes the window, the middle one
doesn't get taller or --err, less tall?-- during the resizing.

On a whim, I also tried "width:90%" but that resulted in the div
growing as tall as the "something tall" inside it.
I hope I made it clear what I want. Flame away, if I didn't.

Suggestions?
Kai
Jul 20 '05 #1
11 4433
Kai Grossjohann wrote:
I have this:

<div style="width:100%;height:20px">
bla
</div>
<div style="width:100%;height:???;overflow:scroll">
something
very
tall
so
that
it
produces
a
scrollbar
</div>
<div style="width:100%;height:50px">
another stuff
</div>

The three question marks indicate what I want to put there. What I
want to say is "window height minus 20px minus 50px", but I don't know
how to say it.
Only way is JavaScript AFAIK

My current workaround is to put some JavaScript before </body> which
calculates the height of the window in pixels, subtracts 75 from this
number (75 = 20 + 50 + fudge factor), then frobs the DOM of the
document to say "width:4711px" instead of "width:???".
You mean height:???;, right?

The problem with this workaround is that the corresponding div doesn't
resize when the user resizes the window: while the divs get narrower
or wider properly when the user resizes the window, the middle one
doesn't get taller or --err, less tall?-- during the resizing.


That is possible to detect using JS (the resizing part).
--
Anne van Kesteren
<http://www.annevankesteren.nl/>
Jul 20 '05 #2
Can't you fix the bottom div to the bottom of the viewport so you don't
have to specify a height on the middle?

On Wed, 12 Nov 2003 19:15:18 +0100, Anne van Kesteren wrote:
The three question marks indicate what I want to put there. What I want
to say is "window height minus 20px minus 50px", but I don't know how to
say it.


Only way is JavaScript AFAIK


--

..

Jul 20 '05 #3
Vigil <me@privacy.net> wrote in
news:pa****************************@privacy.net:
Can't you fix the bottom div to the bottom of the viewport so you
don't have to specify a height on the middle?


That causes more problems than it solves. If for whatever reason the
viewport isn't tall enough to display the entire page, then a fixed footer
will stick at the bottom of the viewport and content will scroll underneath
it.
Jul 20 '05 #4
Anne van Kesteren <ma**@annevankesteren.nl> wrote in message news:<bo**********@reader11.wxs.nl>...
Kai Grossjohann wrote:

The problem with this workaround is that the corresponding div doesn't
resize when the user resizes the window: while the divs get narrower
or wider properly when the user resizes the window, the middle one
doesn't get taller or --err, less tall?-- during the resizing.


That is possible to detect using JS (the resizing part).


How to detect this? Do I set a timer that checks every 400ms whether
the window has changed its size, or is there an event that fires when
the user resizes the IE/Mozilla/... window?

Kai
Jul 20 '05 #5
Vigil <me@privacy.net> wrote in message news:<pa****************************@privacy.net>. ..
Can't you fix the bottom div to the bottom of the viewport so you don't
have to specify a height on the middle?


What does it mean to "fix [a] div to the bottom of the viewport"?

Kai
Jul 20 '05 #6
Not if you make the middle scroll?

On Thu, 13 Nov 2003 02:56:01 +0000, Eric Bohlman wrote:
That causes more problems than it solves. If for whatever reason the
viewport isn't tall enough to display the entire page, then a fixed footer
will stick at the bottom of the viewport and content will scroll
underneath it.


--

..

Jul 20 '05 #7
Kai Grossjohann wrote:
That is possible to detect using JS (the resizing part).

How to detect this? Do I set a timer that checks every 400ms whether
the window has changed its size, or is there an event that fires when
the user resizes the IE/Mozilla/... window?

Kai

I think you need something like this:
<http://www.google.com/search?q=javascript+onresize> ;-)
--
Anne van Kesteren
<http://www.annevankesteren.nl/>
Jul 20 '05 #8
Anne van Kesteren <ma**@annevankesteren.nl> writes:
I think you need something like this:
<http://www.google.com/search?q=javascript+onresize> ;-)


Ah, it seems the JavaScript reference I'm using is incomplete...

Kai
Jul 20 '05 #9
CJM
"Vigil" <me@privacy.net> wrote in message
news:pa****************************@privacy.net...
Not if you make the middle scroll?

And how do you do that?
Jul 20 '05 #10
"CJM" <cj*****@yahoo.co.uk> writes:
"Vigil" <me@privacy.net> wrote in message
news:pa****************************@privacy.net...
Not if you make the middle scroll?

And how do you do that?


<div style="overflow:scroll;...">...</div>

This will create scrollbars. But I /think/ that it is also necessary
to specify the height, otherwise the div will just grow to accomodate
its contents.

Which brings us back to square one where I asked how to specify the
height ;-)

Kai
Jul 20 '05 #11
Kai Grossjohann wrote:
"CJM" <cj*****@yahoo.co.uk> writes:

"Vigil" <me@privacy.net> wrote in message
news:pa****************************@privacy.net. ..
Not if you make the middle scroll?

And how do you do that?

<div style="overflow:scroll;...">...</div>


overflow:auto;

Is a better solution IMHO. Then it will only create scrollbars when they
are needed.

This will create scrollbars. But I /think/ that it is also necessary
to specify the height, otherwise the div will just grow to accomodate
its contents.

Which brings us back to square one where I asked how to specify the
height ;-)

Kai

--
Anne van Kesteren
<http://www.annevankesteren.nl/>
Jul 20 '05 #12

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

Similar topics

12
by: bhennon | last post by:
Hey all, I have a small php script that calls a random image at the following page. http://www.2006ymcanationals.com/random.php IT WORKS IF I go directly to the above link. I am trying to...
0
by: BW | last post by:
Please ignore the rest of the code, except for the highlighted part (or the line 'ent1=Entry(topf, width=25)' to line 'ent1.insert(INSERT, wrong, if you cannot see the color). You can copy this into...
8
by: Ryan R. Rosario | last post by:
Hi - **I apologize for posting this again. I dont think my first one went thru** I am in the process of converting a table based website over to a CSS based website and I am having a problem....
2
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the...
145
by: Sidney Cadot | last post by:
Hi all, In a discussion with Tak-Shing Chan the question came up whether the as-if rule can cover I/O functions. Basically, he maintains it can, and I think it doesn't. Consider two...
7
by: bijax | last post by:
hi, i am new to multidimensional array of c programming .pls help me to solve out this how to allocate memory for mutidimensional array? i.e a ;
12
by: Olaf Baeyens | last post by:
I am porting some of my buffer class code for C++ to C#. This C++ class allocates a block of memory using m_pBuffer=new BYTE; But since the class is also used for pointers for funtions that uses...
13
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
17
by: Chen Shusheng | last post by:
Hi all, In fact, I want to let my memory run out. And see what will happen. My system is windowsXp. Memory is 256M.I think my cdes will apply more memory than I have. Codes are below: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.