473,803 Members | 4,192 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
15 3771
Garmt de Vries <gd******@phys. uu.nl> wrote:
On Mon, 19 Jan 2004, Lauri Raittila wrote:
In article Steve Pugh wrote:
> http://steve.pugh.net/test/test66.html


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


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.


For my method just float the content right instead of floating the nav
left. The content now has width:75%; and the nav has margin-right:
75%;, the image and styles for the background remain unchanged.

With Lauri's method this sort of simple swap isn't as easy. A
position: based method like Lauri's second suggestion is more amenable
to that sort of manipulation.

However, I've just thought of something else. Let me see if it
works...

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 #11
Steve Pugh <st***@pugh.net > wrote:
However, I've just thought of something else. Let me see if it
works...


http://steve.pugh.net/test/test66-em.html

It works. Though I'm certain that in theory it should break when the
nav is longer than both the content and the window, but it doesn't
seem to in my test browsers (Opera 5 and 7.23, IE 5.01 and 6, Netscape
6, Mozilla 1.5). Even degrades fairly gracefully in Netscape 4.

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 #12
On Tue, 20 Jan 2004, Steve Pugh wrote:
Steve Pugh <st***@pugh.net > wrote:

http://steve.pugh.net/test/test66-em.html

It works. Though I'm certain that in theory it should break when the
nav is longer than both the content and the window, but it doesn't
seem to in my test browsers (Opera 5 and 7.23, IE 5.01 and 6, Netscape
6, Mozilla 1.5). Even degrades fairly gracefully in Netscape 4.


Yes, this looks good. Needs a larger background image, but that can be
taken care of.

I put your method in my ply-around script at
http://www.phys.uu.nl/~gdevries/test/pugh2.cgi to test for various font
sizes and menu/content heights.

It works fine in Opera 7.21 (Linux), Konqueror 3.03 (Linux) too.

Thanks a lot!

Best,
Garmt.
Jul 20 '05 #13
In article Garmt de Vries wrote:
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?


You aren't, it took 30 seconds to change it:
http://www.student.oulu.fi/~laurirai...on/index3.html
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.


Really? Yes it seems to do now. I tested it god knows how many times and
couldn't get it break. I must have changed something accidentally. It
seems worse way anyway, so it is not big problem
--
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 #14
Stephen Poley wrote:
On Mon, 19 Jan 2004 17:21:40 GMT, Brian wrote:
http://www.tsmchughs.com/

On long pages, the green nav only extends a bit below the first
screen. Beneath that, it changes to white.


Not sure, but does this help?
http://www.xs4all.nl/~sbpoley/webmatters/layout3.html


Thanks for the link to the layout idea. It doesn't work for me because
#navigation has position: absolute. On balance, I'd rather keep the
nav in a sensible place in the html than have the green extend down
the page as I'd like.

It's a real pity that I can't use display: table-cell with position:
absolute; that would at least solve the problem in Safari, Moz, and Opera.

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

Jul 20 '05 #15
In article Brian wrote:
Thanks for the link to the layout idea. It doesn't work for me because
#navigation has position: absolute. On balance, I'd rather keep the
nav in a sensible place in the html than have the green extend down
the page as I'd like.

It's a real pity that I can't use display: table-cell with position:
absolute; that would at least solve the problem in Safari, Moz, and Opera.


I don't think your structure will change worse if you wrap all content
exept menu in one div, and give it suitable green left border. Then it
works in IE. That is what I tried to write in my other post.

--
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 #16

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

Similar topics

157
16462
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
23010
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
2494
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
1725
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
2018
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
4782
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
9703
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
10548
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...
0
10316
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
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
10069
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
9125
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
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
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.