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

forcing div to take all available height between two divs

I have absolutely positioned, fixed size div (mainDiv) on a page, inside which a header(headerDiv) , a div containing data (dataDiv) and a footer(footerDiv) should be displayed. Scrollbars should be shown if there is too much data to fit inside containing div.

The problem is that headerDiv has variable height, so dataDiv can't have fixed height defined, but should take all available height that remains in mainDiv

Expand|Select|Wrap|Line Numbers
  1. <style>
  2.  
  3. #mainDiv{
  4. position:absolute;
  5. left:100px;
  6. top:100px;
  7. width:500px;
  8. height:500px;
  9. }
  10.  
  11. #headerDiv{
  12. width:100%;
  13. }
  14.  
  15. #dataDiv{
  16. width:100%;
  17. overflow:auto;
  18. height:???
  19. }
  20.  
  21. #footerDiv{
  22. width:100%;
  23. height:20px;
  24. }
  25.  
  26. </style>
  27.  
  28. <div id="mainDiv">
  29. <div id="headerDiv">
  30. Header with height based on content
  31. </div>
  32. <div id="dataDiv">
  33. Variable data, scrollable if container height is exceeded
  34. </div>
  35. <div id="footerDiv">
  36. Fixed size footer
  37. </div>
  38. </div>
I have been experimenting with different css properties and checked numerous forums but could not find appropriate solution. Does anyone knows a css solution to this seemingly simple problem or is Javascript the only option?

thanx

Simon
Aug 23 '07 #1
1 5678
epots9
1,351 Expert 1GB
Hi JesenkoS welcome to TSDN,

try this:
Expand|Select|Wrap|Line Numbers
  1. #headerDiv{
  2. width:100%;
  3. height:20%
  4. }
  5.  
  6. #dataDiv{
  7. width:100%;
  8. overflow:auto;
  9. height:60%
  10. }
  11.  
  12. #footerDiv{
  13. width:100%;
  14. height:20%;
  15. }
  16.  
play around with the percentages to get it looking the way u want.
good luck
Aug 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Duane Lambe | last post by:
On some suggestions from this group, I've started to turn my internal helpdesky site for our company to non-absolute positioning. I've been reading O'Reilly's CSS book, and several web sites and...
6
by: Finn Newick | last post by:
By defining a style as follows: @media aural, handheld {td.layout {display:block;}} I'm hoping to linearise layout tables when viewed by screenreaders and handheld devices (it is also be in...
3
by: Rennie deGraaf | last post by:
Is it possible to force adjacent block elements to have the same height, without specifying that height? In this page (http://pages.cpsc.ucalgary.ca/~degraaf/test/index3.html), I have a bunch of...
6
by: veerleverbr | last post by:
Hi, I have the following html: <div id="content"> <div id="leftpart">...</div> <div id="rightpart">...</div> </div> leftpart en rightpart are in the css set to float left. The content of...
5
by: shanti.miller | last post by:
I've got a grid that uses paging and displays a maximum of 10 records at a time. Sometimes the fields have a lot of data in them and the datagrid takes up way too much horizontal space. I've...
4
by: atma86 | last post by:
what up people, i'm writing an app which includes a page that has 2 divs side by side. the page is set up to fill the table containing the divs to 100% of the width of the pages. I want the height...
1
by: avocado12 | last post by:
Hi, I'm pretty new to web development and I just spent the better part of the morning trying to figure out this IE bug. I came up with a hack that makes no sense to me. I would appreciate if...
2
by: damezumari | last post by:
I have three div blocks defined like this: #left1 { float: left; background-color: white; width: 184px; margin-right: 4px; text-align: left; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.