473,789 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

div height problem for coloured column

I would have guessed that this issue had been discussed to death, but I
couldn't find an answer to my problem in the ciwas archives. So, at the
risk of asking something trivial, here goes:

I want to have a page that looks as follows: at the left, a blue column
with a navigation menu. The rest of the page, with a white background, is
for the content. The blue fades smoothly into the white.

I managed to do this by using a background image for the body, repeated
vertically. This image is a 200px wide blue field, with a smooth
transition to white. A div with the menu is absolutely positioned at
the right, so it overlaps the blue of the background image. You can see
the result at http://www.phys.uu.nl/~gdevries/test/goal.cgi

The problem with this solution is that I have to specify the width of the
menu in px. I would of course prefer to specify it in em, but then the
trick with the background image doesn't work.

The best I could do so far is to set the background-color of the menu div
to blue and its height to 100%. According to the CSS2 specs, its height
should then be the height of the containing box, which is the body. I
understand from previous posts that the height of the viewport is taken in
this case.

Now if the content is taller then the height of the viewport, and you
scroll down, you see that the menu div with its background colour is
really only as high as the viewport; underneath you see the body
background colour: see http://www.phys.uu.nl/~gdevries/test/test.cgi

My question is: how can I make this menu div stretch all the way to the
bottom of the body?

I have read numerous posts about centering in the viewport, or filling the
viewport if the content is short, but no answer to this particular
question.

Thanks for any thoughts you can give!

Garmt de Vries.
Jul 20 '05 #1
15 3770
Garmt de Vries wrote:
I would have guessed that this issue had been discussed to death, but I
couldn't find an answer to my problem in the ciwas archives. So, at the
risk of asking something trivial, here goes:


[table-like layout]

You want a table-like layout. So you have to use the table* values for
the display property (CSS, don't work in WinIE <= 6.0) or use HTML tables.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Jul 20 '05 #2
Garmt de Vries <gd******@phys. uu.nl> wrote:
I want to have a page that looks as follows: at the left, a blue column
with a navigation menu. The rest of the page, with a white background, is
for the content. The blue fades smoothly into the white.

I managed to do this by using a background image for the body, repeated
vertically. This image is a 200px wide blue field, with a smooth
transition to white. A div with the menu is absolutely positioned at
the right, so it overlaps the blue of the background image. You can see
the result at http://www.phys.uu.nl/~gdevries/test/goal.cgi

The problem with this solution is that I have to specify the width of the
menu in px. I would of course prefer to specify it in em, but then the
trick with the background image doesn't work.


I can't think of a way to do it with ems (other than nasty stuff with
z-index and em scaled images), but the following works with percentage
sized columns: http://steve.pugh.net/test/test66.html

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #3
In article Garmt de Vries wrote:
I want to have a page that looks as follows: at the left, a blue column
with a navigation menu. The rest of the page, with a white background, is
for the content. The blue fades smoothly into the white.
That's easy.
I managed to do this by using a background image for the body, repeated
vertically. This image is a 200px wide blue field, with a smooth
transition to white. A div with the menu is absolutely positioned at
the right, so it overlaps the blue of the background image. You can see
the result at http://www.phys.uu.nl/~gdevries/test/goal.cgi
Server seems to have some slowdown... You are right that it is not good
solution. Anyway you could use em and huge white area on right of image,
and blue body backgroud. That might degrade badly though
Now if the content is taller then the height of the viewport, and you
scroll down, you see that the menu div with its background colour is
really only as high as the viewport; underneath you see the body
background colour: see http://www.phys.uu.nl/~gdevries/test/test.cgi
Replace CSS that you have with this:
---
html, body {margin:0;paddi ng:0;height:100 %; background:yell ow}
[foo], html, body, #menu {min-height:100%;hei ght:auto;}

#content {
background: url("transition .gif") yellow repeat-y;
border-left:blue solid 15em;
margin-left: -40px;
/* This padding has to have some value, as collapsing margins work in
Opera 7*/
padding:0.5em;
padding-left:60px;

}

#menu {
background: url("transition .gif") blue right repeat-y;
position: absolute; top: 0; left: 0;
height:100%;
width: 15em;
}
---

Practically, have that transition picture in both parts, and position
them one over another.

There is also some code that tries to make menu at least as high as
viewport. Not tested exept Opera 7.5p1, might work on IE, Might work on
Mozilla and maybe in others too. [foo] is supposed to hide rule from IE,
but I'm not sure if I recalled correctly how to use it...

If you don't need ot to be as high as viewport, just remove all vertical
stuff.
I have read numerous posts about centering in the viewport, or filling the
viewport if the content is short, but no answer to this particular
question.


I have answered it few times, exept not exactly in this form. Usually it
is about border in between ;-)
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #4
In article Steve Pugh wrote:

[transition of color in middle of page]
I can't think of a way to do it with ems [...], but following
works with percentage sized columns:
http://steve.pugh.net/test/test66.html


Hm. I managed to think two ways, but I haven't tested them much, just
Opera 7.5p1:

http://www.student.oulu.fi/~laurirai...ion/index.html
http://www.student.oulu.fi/~laurirai...on/index2.html

Maybe I will get some testing done sometime, but now I need to go buy
some food.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #5
> In article Garmt de Vries wrote:
Now if the content is taller then the height of the viewport, and you
scroll down, you see that the menu div with its background colour is
really only as high as the viewport; underneath you see the body
background colour: see http://www.phys.uu.nl/~gdevries/test/test.cgi

I was hoping to glean some information from this thread, since I have
the same problem.

http://www.tsmchughs.com/

div#navigation has position absolute, top left, green background. It
should be an easier case, since there's no image involved. Just the
green background for #navigation, and white background for body. On
short pages, I have green for nav, white for body. On long pages, the
green nav only extends a bit below the first screen. Beneath that, it
changes to white. This isn't catastrophic, but it'd look nicer if the
green extended down. I didn't think there was a solution, but still I
tried what was suggested.

Lauri Raittila wrote: html, body {margin:0;paddi ng:0;height:100 %; background:yell ow}
[foo], html, body, #menu {min-height:100%;hei ght:auto;} [selector for bg image snipped; I don't think it was relevant...] #menu {
background: url("transition .gif") blue right repeat-y;
position: absolute; top: 0; left: 0;
height:100%;
width: 15em;
}


I played around with height and min-height on my localhost test
server, with no luck. Tested in MSIE 5/Win, O7.23, and Moz 1.3. Is
there a simple solution that I'm missing?

--
Brian (follow directions in my address to email me)
http://www.tsmchughs.com/

Jul 20 '05 #6
Lauri Raittila <la***@raittila .cjb.net> wrote:
In article Steve Pugh wrote:

[transition of color in middle of page]
I can't think of a way to do it with ems [...], but following
works with percentage sized columns:
http://steve.pugh.net/test/test66.html
Hm. I managed to think two ways, but I haven't tested them much, just
Opera 7.5p1:

http://www.student.oulu.fi/~laurirai...ion/index.html


I like. Very obvious, surprised I didn't think of it. ;-)
http://www.student.oulu.fi/~laurirai...on/index2.html


Hmm, seems rather inelegant. But that appears to be mostly down to the
need to get it working in IE...

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #7
In article Brian wrote:
In article Garmt de Vries wrote:
Now if the content is taller then the height of the viewport, and you
scroll down, you see that the menu div with its background colour is
really only as high as the viewport; underneath you see the body
background colour: see http://www.phys.uu.nl/~gdevries/test/test.cgi

I was hoping to glean some information from this thread, since I have
the same problem.


I answered about this same question few days ago. Independently in
alt.html and sfnet.viestinta .www IIRC. Maybe it is fashionable...

http://www.tsmchughs.com/

div#navigation has position absolute, top left, green background. It
should be an easier case, since there's no image involved.
Maybe, maybe not.
Just the green background for #navigation, and white background for body. On
short pages, I have green for nav, white for body. On long pages, the
green nav only extends a bit below the first screen. Beneath that, it
changes to white.
If I understood you correctly, problem is only in long pages. (so I
ignore short ones)
This isn't catastrophic, but it'd look nicer if the
green extended down. I didn't think there was a solution, but still I
tried what was suggested.
You missed that {border:15em blue solid} in that suggestion - that was
the point in it, height stuff was just experiment.
Is there a simple solution that I'm missing?


This could be what you need:

body {border-left:4px solid green;margin-left:0;}
body > div {border-left:8em solid green;}

Of course that needs lots of work, but your CSS is so hard to follow I
gave up. IE certainly don't get it whitout changes.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #8
On Mon, 19 Jan 2004 17:21:40 GMT, Brian
<us*****@juliet remblay.com.inv alid-remove-this-part> wrote:
I was hoping to glean some information from this thread, since I have
the same problem.

http://www.tsmchughs.com/

div#navigati on has position absolute, top left, green background. It
should be an easier case, since there's no image involved. Just the
green background for #navigation, and white background for body. On
short pages, I have green for nav, white for body. On long pages, the
green nav only extends a bit below the first screen. Beneath that, it
changes to white. This isn't catastrophic, but it'd look nicer if the
green extended down. I didn't think there was a solution, but still I
tried what was suggested.


Not sure, but does this help?

http://www.xs4all.nl/~sbpoley/webmatters/layout3.html

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #9
On Mon, 19 Jan 2004, Lauri Raittila wrote:
In article Steve Pugh wrote:

[transition of color in middle of page]
I can't think of a way to do it with ems [...], but following
works with percentage sized columns:
http://steve.pugh.net/test/test66.html


Hm. I managed to think two ways, but I haven't tested them much, just
Opera 7.5p1:

http://www.student.oulu.fi/~laurirai...ion/index.html
http://www.student.oulu.fi/~laurirai...on/index2.html

Maybe I will get some testing done sometime, but now I need to go buy
some food.


Thanks all for your suggestions.

Steve's method, and Lauri's 1st method seem to work fine on Opera 7.21
(haven't tested others yet). They present one problem, though: they both
require the menu div to come before the content div. Switching off CSS
forces you to go through the entire menu before you reach the content. I
would really like to have the menu after the content in the HTML code.

Perhaps I'm too demanding?

Lauri's second attempt, with an absolutely positioned menu, doesn't pose
this problem. Unfortunately, it doesn't work as intended if you have to
scroll below the lower edge of the viewport... just like my original
attempt.

But your contributions have given me some food for thought. I'll
experiment a bit more.

Thanks,
Garmt.
Jul 20 '05 #10

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

Similar topics

157
16459
by: Dennis | last post by:
Is there some way --using, say, DOM or javascript-- to detect the current pixel width and/or height of a relatively sized table or of one of its columns or rows. I'm going to be writing javascript to adjust my page to the viewer's browser window dimensions and this would sure be great information to have. Thanks .... Dennis
2
6360
by: zing | last post by:
Hello, I want to define n columns that appear with specific background colors, different to the body background (i.e. so you can see the area they occupy). I want the columns to be of the same height but I don't want to use absolute positioning. I want the height to be determined by the height of the longest column. I've defined the columns using inline <span> elements surrounding the column content. All works fine except the height.
11
7887
by: Not4u | last post by:
Hello, I have a problem with CSS code. I want to have one menu column with a fixed width and a 100% height and the rest of the page for content. ---------------- |.|.|<--100%-->| |.M.|----------| |.E.|----------| |.N.|----------| |.U.|----------|
2
23006
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 guidance would be appreciated. To summarize, I would like to have a variable-width, 100% height, left-floating column. However, it seems as though with Mozilla/Netscape that height: 100% is not interpreted as I would
1
2493
by: Derek Fountain | last post by:
I seem to recall from long ago that the TABLE HEIGHT attribute was deprecated (or was Netscape only, or something). Hmmm... I have a web page with a table which controls layout - one row with 3 columns. The left column contains another table containing the left side menu, and the right side column contains another table for the right side menu. The main content of the page goes in the middle. Those two sub-tables are coloured, but as...
3
6626
by: Lamberti Fabrizio | last post by:
I've got the problem described in the table above. I've put a div red with some text inside a TD, but its height is less than 100% of TD height as you can see. I've defined the following styles: div.test { background-color:red; height:100%; width: 100%; } table.test { border: 1px solid #CCCCCC; background-color:yellow; } td.test { border: 1px solid #CCCCCC; }
1
1724
by: Steve Richter | last post by:
I have a simple table with two columns. The first column contains 5 lines of text. The second column contains an iFrame. The iFrame in turn contains a web page. The problem is it does not display at all like I would like it to. I want the column height to expand to the contents of either column. Instead, since I guess the browser does not know the height of the IFrame column, it is the height of column 1 that determines the height. ...
0
2007
by: gferris | last post by:
Hello, I am having an issue with a table that I cannot quite figure out. I have a two-column table with the left column comprising of 4 cells and the right column comprising of one cell with a rowspan of 4 (see http://72.3.212.120/Example1.html). The first three cells in the left column will contain content, as will the one cell in the right column. The fourth cell in the left column is only there to take up the slack in case the content...
6
4780
by: Jeff | last post by:
Nearly identical post in alt.www.webmaster, where it is languishing. I'd like a column that flows the full height of a page, even if you scroll down. If I did this: <div style="width: 100px;height=100%;background-color: red">
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10408
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.