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

Table cell auto stretching vertically when defined height

I am new to HTML and will have to beg if this is obvious, but I am trying to design a table that looks like:

********************************
*----A------*------------------------*
************------------------------*
*------------*------------------------*
*------------*------------------------*
*----B------*------------C----------*
*------------*-------------------------*
********************************

Basically I want A to be defined height of 100 PX and C to vary depending upon the content. B should autostretch to accomodate C. What is happening, however, is that A is stretching beyond the 100 PX. When C is shorter than 100 px, however, A remains at 100 and C will stretch to accomodate.

Below is my code along with CSS sheet.
I have been working on this for a week and can't seem to find out what I am doing wrong. Any help would be much appreciated!!!

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Knights Of Columbus Site</title>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form id="form1" runat="server">
<table id="MainTable" bgcolor="#FFFFFF" align="center">
<tr>
<td id="Banner" colspan="2"><img src="Site_Images/rbanner.jpg"/></td>
</tr>
<tr>
<td id="Sidebarabove" valign="top">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate >
You are not logged in.
</AnonymousTemplate>
<LoggedInTemplate>
Welcome<br />
<asp:LoginName ID="LoginName1" runat="server" />
<br />
<asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="Black" />
</LoggedInTemplate>
</asp:LoginView>
</td>
<td id= "MainContent" valign="top" rowspan="2">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td id="Sidebarbelow" valign="top">
<asp:TreeView CssClass="TreeControl" ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1"
ForeColor="Black" NodeIndent="10" ShowLines="True">
<SelectedNodeStyle Font-Bold="True" />
</asp:TreeView>
</td>
</tr>
<tr>
<td id="BannerBelow" colspan="2"><img src="Site_Images/banbelow.jpg" runat="server"/></td>
</tr>
</table>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>


CSS=

body {
background-color: #000099;
}

#MainTable
{
width: 800px;
}

#Banner
{
height: 150px;
width: 800px;
}

#Sidebarbelow
{
width: 150px;
background-image: url(Site_Images/sideback.jpg);
background-repeat: repeat-y;
height:100%;
}

#Sidebarabove {
width: 150px;
height:100px;
background-image: url(Site_Images/sideback.jpg);
background-repeat: repeat-y;
}

#MainContent {
width: 650px;
height: 100%;
}

#BannerBelow {
height: 90px;
width: 800px;
}

The content page is

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table>
<tr>
<td id="Charter">
<img src="Site_Images/charter.jpg" />
</td>
<td id="Link" valign="top" align="center">
<img src="Site_Images/links.jpg" />
<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="http://www.kofc.org/">Supreme Council Website</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="http://www.kansas-kofc.org/">State Website</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="mailto:Kirby.Schmelzle@ KOFC.ORG">Email Kirby Schmelze-Knights Insurance</asp:HyperLink>

</td>
</tr>
<tr>
</tr>

</table>
</asp:Content>

Kind Regards,
Rob
Nov 24 '06 #1
14 20976
drhowarddrfine
7,435 Expert 4TB
1) It's harder with the asp code tangled in this
2) Tables for layout is stupid
3) I have never used tables for layout so I have a hard time figuring it out. Divs would make this easy.
4) If you say a cell is 100%, it has to be 100% of what? It's the parent of that element. So the parent is what size? If that's not established then you won't get what you want; and so on up the ladder.
Nov 24 '06 #2
Actually, the error occurs with just a simple example--see HTML below. Basically, I am trying to get a table that has two cells on the left and one on the right. I want it so that the top cell on left is fixed height, and the one right below it is the one that will stretch as the one on the right stretches vertically.

If you can show a simply div example of how to do this, it would be much appreciated.

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="newmain.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="725" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id = "top" colspan="2">top</td>
</tr>
<tr>
<td id="sidetop">sidetop</td>
<td id="main" rowspan="2"><img src="charter.jpg" width="326" height="484" /></td>
</tr>
<tr>
<td id="sidebottom"><p>sidebottom</p>
<p>sdfasdf</p>
<p>safda</p>
</td>
</tr>
<tr>
<td id="bottom" colspan="2">bottom</td>
</tr>
</table>
</body>
</html>

CSS:
#top {
height: 150px;
width: 800px;
}
#sidetop
{
height: 100px;
width: 150px;
border-left-color: black;
border-bottom-color: black;
border-top-style: dotted;
border-top-color: black;
border-right-style: dotted;
border-left-style: dotted;
border-right-color: black;
border-bottom-style: dotted;
}
#sidebottom {
height: 100%;
width: 150px;
}
#main {
height: 100%;
width: 650px;
}
#bottom {
height: 150px;
width: 800px;
}
Nov 24 '06 #3
One last thing--If I do this with DIV tags, how can I make the one on the left auto stretch to the main on the right? I am using a repeating background image on the sidebar on the left. If the tag doesn't stretch, then the main will be extending down and the sidebar color will stop at the defined height.
Nov 24 '06 #4
drhowarddrfine
7,435 Expert 4TB
Now you're asking me to work.
Look at this
and through these.

I saw something there similar to what you want.
Nov 25 '06 #5
First, Thank you VERY much for your time. I have to tell you, I'm a very inexperienced newbie at this...and basically learned CSS 2 weeks ago, and was using DWeaver .. and then viewing the resulting code.

The first link you provided does appear to be what I need--although, with absolute positioning..can i still center the table (err...the main "div") on a page..so that I have an area that is a set width that is centered?

Is there an example you can have thats perhaps a little easier to understand or that goes through it with a bit more explanation?

I am trying to do a site for my church (gratis) and appreciate the help---I am sorry if a bother...I thought I was doing fine with the table---I haven't really begun to work with DIV tags.

I can make ID's fairly easily---but anything other than an element rule, class rule or ID rule -- it's a little confusing.

Sigh---any tutorial you can think of that helps with stretching DIV tags?

Basically, what I was trying to do was have a sidebar that will match the height of the main content on the right. The side bar was going to be cut in 2 so that I could have a ASP login status on the top and then a sitemap in the one below that...I'm sure there's plenty of ways to do this--but the central point I need to understand is how to have a sidebar that will autostretch with the content--kinda like your example.

THANK YOU for any help you might be able to provide. I have posted in three different forums and have been working this for a week--you are the first person to reply.

(Basically--having hard time understanding #outer img#top (what the img#top means) and how the rule (not what is defined within) differs from just an #outer rule---what is the difference of what it applies to?)


Kindest Regards,
Rob
Nov 25 '06 #6
drhowarddrfine
7,435 Expert 4TB
I've just been in and out here cause of the holidays so it's just hard to want to concentrate. One place to look for tutorials is w3schools.com which has some good stuff.

The problem you are talking about is one of the few problems with CSS in trying to get columns to keep the same height/length. It's really not that hard but it's not obvious either.
Nov 25 '06 #7
I appreciate your time and completely understand.

Do you happen to know of an easy way to do this with the tables then? Basically have it so that--

<TR>
<TD id="sidetop"/>
<TD id="mainContent" rowspan="2"/>
</TR>
<TR>
<TD id="sidebottom"/>
</TR>

So that when I stretch mainContent, sidebottom is stretched instead of Sidetop?

No rush---just trying to figure easiest way to do this that makes sense.

:)

Happy Holidays!
Rob
Nov 25 '06 #8
AricC
1,892 Expert 1GB
What do you mean that you want to expand the main content? You want that section to expand the width of the page?
Nov 25 '06 #9
No--I'm sorry--what I mean is that I want a sidebar on the left (to have two cells) and a main content page on the right (see table above). What I want is A to always be 100 px and B to actually stretch vertically as C does. With the way tables work--I can't get A to stay--as A & C are in the same <TR>.

Another person said to create a table that is two columns and then put two DIV tags in the left column...

My question is down to this---I am having a hard time understanding how to make a DIV tag stretch vertically...also how to have it so that you can vertically center something in a DIV tag.

So that if I have:

<Table id="table">
<TD id="sidebar">
<DIV id="sidetop"/>
<DIV id="sidebottom"/>
</TD>
<TD id="maincontent"/>
</Table>

#table {width: 800px}
#sidebar {width:150px}
#sidetop {height 100px}
#maincontent(width 650px}

The reason for the table is to get "sidebar" to stretch with "maincontent" while leaving "sidetop" to be a fixed height.

Do you know an easy way of doing this with just DIV tags? Please keep in mind I am a newbie at this (sorry).

Last question--how can I vertically align contents of a DIV tag?

Thanks SO much!
Rob

I have question with above...I want "side top" 'DIV' to be aligned at top, but contents to be vertically aligned.
Nov 26 '06 #10
I think this is what you were asking for...
leftcol.png would be your repeating background image


HTML

<div id="container">

<div id="topleft">
</div>

<div id="content">
</div>

</div>

CSS

body {
margin:0 auto;
padding:0;
text-align: center;
}

#container {
text-align:left;
margin: 0 auto;
width: 800px;
}

#topleft {
float:left;
background:#999;
width:150px;
height:100px;
position:relative;
z-index:1;
}

#content {
background-image:url(leftcol.png);
background-repeat:repeat-y;
background-color:#CCCCCC;
margin-left:-150px;
padding-left:150px;
float:right;
z-index:-1;
width:650px;
min-height:100px;
}
Nov 26 '06 #11
Very close--however (and I have to admit, I am learning on the fly here)--what I am really looking for is a left div that will stretch with the right.

So...your example, the background of the left cell is defined 100 px height.

I might be confusing two things I was working on.

The first thing I was doing was creating a sidebar (left) that really had two div's in it--one on top of the other. One was going to be a login, the other a sitemap.

the content would be on the right.

The top div of the sidebar would be fixed 100px, but the bottom part (the sitemap) would autostretch it's height to match the content on the right.

That was the main thing I was trying to do. To achieve this, I broke it down and figured if I could just learn how to make one column autostretch with the other, I'd be ok.

So--really, all I'm trying to do at this point is find an "easy-to-understand" example of how to put two DIV's side by side and have either stretch it's height to match the other---thus alleviating the need to have a table cell with height=100%..

You example won't autostretch the left to match the right--at least, I dont think--but you might have been doing that to try to solve my "big problem".

At this point, I'd be happy to just understand how to place two div columns side by side and have one match the other when it grows.

Regards,
Rob
Nov 26 '06 #12
If you really want to do this you need to forget about tables all together (except in the instance that you are actually displaying tabular data). I would advise that you have a look at some basic css tutorials to help you understand the differences between css and using tables to do layout.

In my example the top left "column" will always be 150 x 100, and the main content area will stretch with the content, but will never be less than 100px high. Also the background of the lower left "column" will stretch with the content because it is created by the repeating background image attached to the main content div and shifted 150px to the left. To place a sitemap in the lower left you could define another div in the style sheet, position it absolutely below the top left box and apply the same repeating background image.

Transitioning from tables to css is difficult, but I think the best way to learn it is by doing it, and not using tables ever. There are only a very limited number of circumstances where they are appropriate, and trust me you'll be much better off w/out them.

I'll see if I can find some good css tutorials, or alternatively I would recommend CSS Mastery: Advanced Web Standards Solutions by Andy Budd...I still use it almost everyday.
Nov 26 '06 #13
I just realized I didn't include a min-height fix for IE 6 in my example, but I don't want to overwhelm you before you get started. :)
Nov 26 '06 #14
I don't understand why people would consider using tables something stupid. It was pretty much the standard way of doing things before. Now, yes, using DIVs is the absolute best way of laying out a page. People like to pretend they're smarter than others just because they know of a better method - a method that wasn't even discovered by them. "Using tables is stupid." That's pure ignorance. Using tables is absolutely the best way to ensure a layout, it just so happens it doesn't provide for a good design and doesn't scale well. But mind telling me how all those sites got by before DIVs and CSS? I guess the whole WWW was stupid then, huh? It's called progression. There's nothing stupid about things getting better and some not adapting to them as quickly as others.
Mar 16 '07 #15

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

Similar topics

1
by: Kai Grossjohann | last post by:
I have a table which contains a top-aligned table cell: .... <tr style="height:40"> ... <td colspan="1" rowspan="2" align="left" valign="top" style="overflow:hidden;">...
2
by: zwylle | last post by:
Hi all, to avoid a nervous breakdown I finally decided to seek help :D I have a table defined with plain color background and in some cells I show pictures to frame my site. The problem I...
3
by: Thomas Mlynarczyk | last post by:
Hello, How can I make an <a> element (containing text only, styled to be a box with a border) as big as the table cell in which it resides, *without* having specified any width/height (neither...
3
by: kAldam | last post by:
I am currently using IE 6.0 and 5.5 and the scenario is the following. I have a span that contains text, and the span is beign contained by a table cell (this is the way thing need to be in my...
3
by: gscott66 | last post by:
Hello, I am fairly new to design and in particular CSS. I have a site with two tables that I cannot seem to get sized correctly. When you view the link, you'll notice that there is a tremendous...
1
by: Bart Lateur | last post by:
I'm trying to put a utton at the bottom (right) of a TD cell, irrespective of what else is in there. Usually, with other HTML block elements, we're told to use position: relative on the...
4
by: =?Utf-8?B?Qw==?= | last post by:
How do I get the text from my cell e..g. <td>Test Text</td> var elTableCells = elTableRow.getElementsByTagName("td"); alert(elTableCells.innerText);
2
by: Jukka K. Korpela | last post by:
Sub titulo "Re: DIV borders different in IE7 when in td" scripsit Ben C: This seems to be the heart of the matter, and I'm trying to get a real discussion started, by moving the discussion to...
22
Atli
by: Atli | last post by:
Hi. I'm setting up a small photo-album-type thing, where I use PHP to set up a list of images for visitors to click through. That's all simple enough. However, I'm having a weird bug in IE8. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.