Solved

Why does TD height not equal other TD height?

Posted on 2007-11-29
4
457 Views
Last Modified: 2013-11-19
I'm experiencing something very weird I can't really explain.  Basically I'm using DIV layers to contain values which need to be the same height as their corresponding rows in the other DIV layers.  To do this I resize others to the same height as the highest.  Unfortunately after they are set to the new height they aren't really the same height.

I'm including a simple text .html document in this post to help show what I'm experiencing.  Any ideas on how to solve my issue is greatly appreciate.  I'm not adverse to reworking the code, but the key is the black.gif (which is a 1X1 pixel black gif) needs to be 100% width of the row.

Thank you much for your help.
<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASCRIPT>
function test() {
	alert( "Column 1 is " + document.getElementById( "COL1a" ).clientHeight + " pixels high." )
	alert( "Column 2 is " + document.getElementById( "COL2a" ).clientHeight + " pixels high." )
	document.getElementById( "COL2a" ).style.height = document.getElementById( "COL1a" ).clientHeight
	alert( "Column 2 is now " + document.getElementById( "COL2a" ).clientHeight + " pixels high...Not!...Why?" )
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="test()">
<FORM>
 
<DIV ID="COL1" STYLE="position:absolute; width:500px;"><TABLE CELLPADDING=0 CELLSPACING=0><TR>
<TD ID="COL1a">ALKDJ LKJ ALKF DLKF LKF SLKF SDLKF LKDSF LKF LKSD FLK DFL SLDKF LKSDF LKFJ 
LD LKJ SLFKJ<BR><IMG SRC="black.gif" WIDTH=100% HEIGHT=2></TD>
</TR></TABLE></DIV>
 
<DIV ID="COL2" STYLE="position:absolute; left:515px;"><TABLE CELLPADDING=0 CELLSPACING=0><TR>
<TD ID="COL2a">FLKDSJ LK FLKD JF<BR><IMG SRC="black.gif" WIDTH=100% HEIGHT=2></TD>
</TR></TABLE></DIV>
 
</FORM>
</BODY>
</HTML>

Open in new window

0
Comment
Question by:ironclads
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20378893
Change

document.getElementById( "COL2a" ).style.height = document.getElementById( "COL1a" ).clientHeight

to

document.getElementById( "COL2a" ).style.height = document.getElementById( "COL1a" ).clientHeight + 'px';
0
 
LVL 3

Author Comment

by:ironclads
ID: 20382814
I've tried that already and it still doesn't put the height equal to the first column.  Thanks for your idea though.
0
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20383748
The columns do actually become the same height. The contents of the columns is centered vertically, so the content of the right column isn't shown at the bottom of the column.

If you add some color to the columns, you see that they have the same height:

<style>
#COL1 { background: #eee; }
#COL2 { background: #eee; }
</style>

If you want the content of the right column to be at the bottom of the column, you can align it to the bottom:

<TD ID="COL2a" valign="bottom">
0
 
LVL 3

Author Comment

by:ironclads
ID: 20384339
What can I say...duh!  I should have seen that.  It's always the simple things in life that count, that goes for coding too. ;-)  Much Thanks for your help.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
.CSS HTML Help 3 51
How to implement Read More and Read Less with dotdotdot? 4 32
Changing the format from a text box to a drop-down menu 9 32
Jquery syntax 12 20
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question