473,406 Members | 2,451 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,406 software developers and data experts.

Height:100% - XXXpx CSS issue

Okay, I believe this is one of the biggest issues found using CSS/DIV
layout. But, I haven't found a non-Javascript solution.

I would like two DIVs - first DIV, say with a height of 20px. The
second DIV with a height of 100% (the rest of the viewport).

If I do this
<div style="height:20px>
</div>
<div id="MyContainer" style="height:100%">
</div>

MyContainer will have 100% of the height of it's container box (e.g. a
<bodysized 100% to the viewport). At such, I'll not get a container
div with the height of 100% - 20px, which is my goal. I'm looking to
do this without javascript or alternatively, nested tables (which is a
CSS nightmare cross-browser).

Is this possible? If not, I'll go the javascript route, but... Is CSS
this limited?

Thanks,

- Mike
Sep 24 '08 #1
7 4586
In article
<c7**********************************@z11g2000prl. googlegroups.com>,
msoliver <mi************@gmail.comwrote:
Okay, I believe this is one of the biggest issues found using CSS/DIV
layout. But, I haven't found a non-Javascript solution.

I would like two DIVs - first DIV, say with a height of 20px. The
second DIV with a height of 100% (the rest of the viewport).
There are different ways to skin this cat (your description is not quite
accurate but I sort of know what you mean).

This looks ok in FF 3, Safari 3 and iCab 4, Opera 9.5:

<http://dorayme.890m.com/alt/px_percent_heights.html>

--
dorayme
Sep 24 '08 #2
On Sep 23, 6:44*pm, dorayme <doraymeRidT...@optusnet.com.auwrote:
In article
<c7b0dac0-dbc9-44cf-9a06-576cfef57...@z11g2000prl.googlegroups.com>,

*msoliver <michaelsoli...@gmail.comwrote:
Okay, I believe this is one of the biggest issues found using CSS/DIV
layout. But, I haven't found a non-Javascript solution.
I would like two DIVs - first DIV, say with a height of 20px. The
second DIV with a height of 100% (the rest of the viewport).

There are different ways to skin this cat (your description is not quite
accurate but I sort of know what you mean).

This looks ok in FF 3, Safari 3 and iCab 4, Opera 9.5:

<http://dorayme.890m.com/alt/px_percent_heights.html>

--
dorayme
Thanks, but unfortunately, there is a problem with your solution:

DIV top is 20 px high and DIV rest is 100% high. DIV rest appears to
be 100% - 20px, but it's the full height of the viewport. You can see
this if you remove the background of the top div. So, what's going on
is the top DIV is 20px and then the rest DIV is just layered
underneath the top DIV, but takes 100% of the viewport. The padding-
top: 20px makes the DIV rest content display in the right place, but
when I replace it with real content, it's clear that the height is
off...

Thanks.

- Mike
Sep 24 '08 #3
In article
<52**********************************@v16g2000prc. googlegroups.com>,
msoliver <mi************@gmail.comwrote:
On Sep 23, 6:44*pm, dorayme <doraymeRidT...@optusnet.com.auwrote:
In article
<c7b0dac0-dbc9-44cf-9a06-576cfef57...@z11g2000prl.googlegroups.com>,

*msoliver <michaelsoli...@gmail.comwrote:
Okay, I believe this is one of the biggest issues found using CSS/DIV
layout. But, I haven't found a non-Javascript solution.
I would like two DIVs - first DIV, say with a height of 20px. The
second DIV with a height of 100% (the rest of the viewport).
There are different ways to skin this cat (your description is not quite
accurate but I sort of know what you mean).

This looks ok in FF 3, Safari 3 and iCab 4, Opera 9.5:

<http://dorayme.890m.com/alt/px_percent_heights.html>

--
dorayme

Thanks, but unfortunately, there is a problem with your solution:

DIV top is 20 px high and DIV rest is 100% high.
which was one of your descriptions. You see, there is a contradiction in
your description and I took one of the horns on the principle of
charitable interpreation. You said 100% and I assumed this is 100% of
viewport. True, you also said the second div should be "the rest"
implying viewport minus 20px. But no one can know what percentage this
is so unless one knows exactly what the user has opened his browser to
(js come to mind). Why did you mention a percentage? Surely not for the
vacuous reason that anything at all is 100% of what it is?

DIV rest appears to
be 100% - 20px, but it's the full height of the viewport. You can see
this if you remove the background of the top div. So, what's going on
is the top DIV is 20px and then the rest DIV is just layered
underneath the top DIV, but takes 100% of the viewport. The padding-
top: 20px makes the DIV rest content display in the right place, but
when I replace it with real content, it's clear that the height is
off...
When you replace the 20px high dive with real content? You can't get
much content in 20px high!

Is there a chance that you can post a URL with almost the same length
and type of content you want. Otherwise we are just playing theoretical
games with not quite well defined parameters. It is best for me to
understand what you are wanting to do on the whole. I gave you 100% div,
I gave you 20px div and like little Thomas the Tank Engine, I tried my
very best

--
dorayme
Sep 24 '08 #4
I appreciate all of your help. How about I just show the HTML -
hopefully this will explain things better. I cleaned up the HTML a bit
for clarify sake.

I have a surrounding DIV, GridDiv. Then I have two child divs,
HeadingDiv, and DataDiv. GridDiv is already expanded to 100% of the
viewport. I want HeadingDiv to be 20px,which is easy enough. And then
I want DataDiv to take the rest of the viewport's height (100% -
20px). If I added padding-top to DataDiv, I see the first table row.
However, as the Data Table grows, the scroll bar will show up and take
up the full viewport's height (which is how I noticed that the second
div is still 100% of the viewport, not 100% - 20px... Make more sense?

Thanks!

<body onload="onload()">
<div id="GridDiv">
<div id="HeadingDiv">
<table cellspacing="0" cellpadding="0">
<tr>
<td class="cell">Col1</td>
<td class="cell">Col2</td>
<td class="cell">Col3</td>
<td class="cell">Col4</td>
<td class="cell">Col5</td>
<td></td>
</tr>
</table>
</div>
<div id="DataDiv" >
<table id="DataTable" cellspacing="0" cellpadding="0">
<tr>
<td class="cell">Data1</td>
<td class="cell">Data1</td>
<td class="cell">Data1</td>
<td class="cell">Data1</td>
<td class="cell">Data1</td>
</tr>
<tr>
<td class="cell">Data2</td>
<td class="cell">Data2</td>
<td class="cell">Data2</td>
<td class="cell">Data2</td>
<td class="cell">Data2</td>
</tr>
<tr>
<td class="cell">Data3</td>
<td class="cell">Data3</td>
<td class="cell">Data3</td>
<td class="cell">Data3</td>
<td class="cell">Data3</td>
</tr>
</table>
</div>
</div>
</body>
Sep 24 '08 #5
In article
<46**********************************@n33g2000pri. googlegroups.com>,
msoliver <mi************@gmail.comwrote:
I appreciate all of your help. How about I just show the HTML -
hopefully this will explain things better. I cleaned up the HTML a bit
for clarify sake.

I have a surrounding DIV, GridDiv. Then I have two child divs,
HeadingDiv, and DataDiv. GridDiv is already expanded to 100% of the
viewport. I want HeadingDiv to be 20px,which is easy enough. And then
I want DataDiv to take the rest of the viewport's height (100% -
20px). If I added padding-top to DataDiv, I see the first table row.
However, as the Data Table grows, the scroll bar will show up and take
up the full viewport's height (which is how I noticed that the second
div is still 100% of the viewport, not 100% - 20px... Make more sense?

Thanks!

<body onload="onload()">
<div id="GridDiv">
<div id="HeadingDiv">
<table cellspacing="0" cellpadding="0">
<tr>
<td class="cell">Col1</td>
<td class="cell">Col2</td>
<td class="cell">Col3</td>

Hi, it's me, Thomas the Tank Engine back. I talked to my big brother,
The Scotland Express (A shielder that goes through Manchester and
particularly Didsbury) and he calmed me down.

Why don't you supply a URL, do not put in js instructions if they are
not doing anything, explain within the table cells if need be what it is
you would like to see that cell or that row or this table to be doing.
How about making a diagram in Photoshop or Illustrator or any program
you like. How about hand drawing it and scanning it and posting it as a
picture to a public server where we can see it.

Thomas here is orfffff for a swim in the sea (I know! Salt and steel....
never mind, will take a risk), being how lovely it is this fine spring
Sydney day.

--
dorayme
Sep 24 '08 #6
msoliver schrieb:
At such, I'll not get a container
div with the height of 100% - 20px, which is my goal.
[...]
Is this possible?
Try an absolutely positioned block with "top: 20px; bottom: 0". Browser
support may vary.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Sep 24 '08 #7
On 2008-09-24, msoliver <mi************@gmail.comwrote:
I appreciate all of your help. How about I just show the HTML -
hopefully this will explain things better. I cleaned up the HTML a bit
for clarify sake.

I have a surrounding DIV, GridDiv. Then I have two child divs,
HeadingDiv, and DataDiv. GridDiv is already expanded to 100% of the
viewport. I want HeadingDiv to be 20px,which is easy enough. And then
I want DataDiv to take the rest of the viewport's height (100% -
20px). If I added padding-top to DataDiv, I see the first table row.
However, as the Data Table grows, the scroll bar will show up and take
up the full viewport's height (which is how I noticed that the second
div is still 100% of the viewport, not 100% - 20px... Make more sense?
Just use absolute positioning as somebody suggested.

#HeadingDiv
{
position: absolute;
top: 0;
left: 0;
right: 0;
height: 20px;
}
#DataDiv
{
position: absolute;
top: 20px;
left: 0;
right: 0;
bottom: 0;
}
Sep 25 '08 #8

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

Similar topics

1
by: Ron Bott | last post by:
I have a layout that has a fixed size #container <div> with a shadow running along the right side that encloses the content area. I would like the shadow background to extend to the full height of...
2
by: patrick h. | last post by:
Greetings, I am encountering some issues regarding using float while desiring to set the height to 100%. This is likely due to my own misunderstanding of the way things actually function -- any...
3
by: Raghavendra | last post by:
Hi All, Here is my code. ------------------------------------------- <div style="height:100%"> <BODY> sample text spanning about 30 lines </BODY> </div>...
5
by: esingley | last post by:
I've done a lot of poking around the web and this newsgroup and have seen a number of answers to this question. But, I wanted to appeal to the experts here one last time before I decide to let the...
6
by: jslaybaugh | last post by:
I'm working on an ASP.NET 2.0 application and am having trouble with a very simple table layout. Using ASP.NET 2.0 it defaults to XHTML 1.0 Transitional and I am trying to comply. However, I...
4
by: reycri | last post by:
I have a page that works as I intend in IE but not in Firefox: <html> <head> <title>Overflow Test</title> </head> <body style='overflow:hidden; margin:0; padding:0;'> <table border='0'...
0
by: Markus Olderdissen | last post by:
i want to create my page with 100% height. <table height="100%"works but is not correct by default. i saw various information how to do it with stylesheet. i really have problems to create my page....
5
by: Dag Sunde | last post by:
I ran into a problem i just *know* I've seen described a 100 times before I have an empty (so far) div with ist height: set to 100%. The main reason for this div is to show its white border-right...
2
by: EmersonUK | last post by:
I’ve worked around a couple of times with DIVs using height:100% and I had no problems at all, testing on many browsers (IE7, FF3, FF2, Opera, Safari and Chrome). Now I’ve tried the same idea on a...
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
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
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
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
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.