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 6060181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:47:46+00:00 2026-05-23T08:47:46+00:00

I have a HTML table like the below; <table style=width: 100%> <tr> <td style=width:

  • 0

I have a HTML table like the below;

<table style="width: 100%">
<tr>
<td style="width: 30px">cell</td>
<td class="cell">cell</td>
<td class="cell">cellcell</td>
<td class="cell">cellcellcell</td>
<td class="cell">cellcellcellcell</td>
<td class="cell">cellcellcellcellcell</td>
<td class="cell">cellcellcellcellcellcell</td>
<td style="width: 30px">cell</td>
</tr>
</table>

The table is designed to stretch to screen (or a div having specific width). I want equal width for all cells having class="cell" and this works well when the character length of text in all cells having class="cell" are equal. But, I want to fix the cell width even if the character lengths of contents in class="cell" are different.

Also you can see that the first and last cells have fixed width, in pixels and others cell widths are to be calculated on the basis of percentage .. I want equal width for all cells (except first and last with fixed width in pixels).

I think this can be done using Javascript with the help of jQuery, by calculating the table cell widths on document ready, and then adding some function using on window resize and thereby calculating cell widths. The cell widths will be (tablewidth in px - 60px)/6 I am a beginner and I don’t know much.. How can I do this using jQuery and (or) Javascript.

It will be very helpful if someone make me a fiddle..

  • 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-23T08:47:47+00:00Added an answer on May 23, 2026 at 8:47 am

    You could just do that with CSS, by applying each td an equal percentage:

    td{
     width:   16%;
    }
    

    example: http://jsfiddle.net/niklasvh/wKmxD/

    With your updated question, you could do it with javascript by first storing the widths into an array, and then referencing that on window resize, and use the aspect ratio difference to place new widths:

    var w = [];
    var tw = $('table').width();
    $('table td').width(function(i,e){
        w[i]=e;
    });
    
    $(window).resize(function(){
        $('table td').width(function(i){
        return ($('table').width()/tw)*w[i];
        });
    });
    

    http://jsfiddle.net/niklasvh/543D9/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html table <table border=0 width=100%> <tr class=headerbg> <th width=5%> No </th>
I have the following: <ul style=width: 300px; list-style-type:none> <li> <table style=width:100% border=0 cellpadding=0 cellspacing=0
I have an html table like below +-------+-------+-------+-------+-------+---------+---------+---------+---------+ | col1 | col2 | col3
I have an HTML table that looks like this: ------------------------------------------------- |Column 1 |Column 2
Let's say I have the following HTML: <table id=foo> <th class=sortasc>Header</th> </table> <table id=bar>
I would like to have a border for the table with class name as
Consider I have a table, like below, that I am trying to populate with
I have an html table which i bind data dynamically on the server side
I have an HTML table with several columns and I need to implement a
I have a very specific html table construct that seems to reveal a Gecko

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.