Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 909221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:50:32+00:00 2026-05-15T16:50:32+00:00

I need to align rows in different tables that are layed out horizontally. I’d

  • 0

I need to align rows in different tables that are layed out horizontally. I’d prefer to put the html code in a single web user control so I can create as many instances of that control as I want and lay them out horizontally. The problem is, the text in the rows needs to wrap. So some rows may expand vertically and some may not (see the example below). When that happens, the rows in the other tables aren’t aligned horizontally. I know I can accomplish all this by using a single table, but that would mean I’d have to duplicate the name, address and phone html code instead of dynamically creating new instances of my user control (in reality there are many more fields than this, but I’m keeping it simple). Is there any way to do this whether with div’s, tables or something else?

Here’s the problem: Mary Jane’s address field expands 2 lines, causing her phone field to not align properly with John’s and Bob’s.

Name:  John Doe           Name: Mary Jane                   Name: Bob Smith 
Address: 123 broadway     Address: Some really long address Address: Short address 
Phone: 123-456            that takes up multiple lines      Phone: 111-2222 
                          Phone: 456-789

I’m not restricted in any way how to do this (other than using asp.net), but I’d prefer to use a single web control that I instantiate X times at design time (in this example, it’s 3 times). I’m using VS2008, and .Net 3.5

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:50:33+00:00Added an answer on May 15, 2026 at 4:50 pm

    Just so everyone knows, this is possible. I finished the solution using jquery and it works pretty well. I assigned each table a specific css class and used that to identify which tables need to be resized (don’t want to use an id since each one must be unique). It works in the 4 major browsers. For IE7 make sure to add a space in the empty cells for this to work. Here’s the Javascript:

    function ResizeTableRows() {
        // select tables by css class name using jquery
        var tables = $('.myCssClassName');
    
        // all tables should have the save number of rows, so just use the first one
        var totalRows = tables[0].rows.length;
    
        for (var rowNumber = 0; rowNumber < totalRows; rowNumber++) {
            var maxRowHeight = GetMaxRowHeight(tables, rowNumber);
    
            for (var i = 0; i < tables.length; i++) {
                if (maxRowHeight > 0) {
                    tables[i].rows[rowNumber].height = maxRowHeight;
                    SetCellHeight(tables[i].rows[rowNumber].cells, maxRowHeight);
                }
            }
        }
    }
    
    function GetMaxRowHeight(tables, rowNumber) {
        var maxRowHeight = 0;
    
        for (var i = 0; i < tables.length; i++) {
            var row1 = tables[i].rows[rowNumber];
            var cell1 = row1.cells[0];
            var rowHeight = row1.clientHeight;
    
            if (rowHeight <= 0) {
                rowHeight = row1.height;
            }        
            if (rowHeight <= 0) {
                rowHeight = cell1.clientHeight;
            }        
    
            if (rowHeight > maxRowHeight) {
                maxRowHeight = rowHeight;
            }
        }
        return maxRowHeight;
    }
    
    function SetCellHeight(cells, maxRowHeight) {
        for (var i = 0; i < cells.length; i++) {
            cells[i].height = maxRowHeight;
        }
    }
    

    Here’s the code to start the process. Add it to the main page and not the web control (if you’re using .net)

    <script type="text/javascript">
        // runs automatically after this page has been loaded and rendered
        $(document).ready(function() {
            ResizeTableRows();
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.