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

  • Home
  • SEARCH
  • 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 9028999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:08:34+00:00 2026-06-16T07:08:34+00:00

I am attempting to create a scrolling table with a fixed header. Problem is

  • 0

I am attempting to create a scrolling table with a fixed header. Problem is that the columns between the <thead> and the <tbody> are not matched correctly. My question is how can I get the columns to match in a scrolling table with fixed headers.

Below is the fiddle, just click on the “Add Question” button 3 times and then scroll the table:

http://jsfiddle.net/6rCyH/2/

Below is the html of the table:

<table id="qandatbl" align="center">
<thead class="tblhead">
<tr>
    <th class="qid">Question No</th>
    <th class="question">Question</th>
    <th class="optandans">Option and Answer</th>

</tr>
</thead>
<tbody class="tblbody">
</tbody>
</table>

Below is the main css which controls the table and each column:

body{
    font-size:85%;  
}           

.extratd{
    border:1px black solid;
    border-collapse:collapse;
}

.qid { 
    min-width:3%;
    max-width:3%;
    font-weight:bold;
    border:1px black solid;
    border-collapse:collapse;
}

.question { 
    min-width:14%;
    max-width:14%;
    border:1px black solid;
    border-collapse:collapse;
}

.question textarea {
    min-width:auto;
    max-width:auto;
    resize:none;
    height:100%;
    font-size:100%;
}

.noofanswers{
    min-width:15%;
    max-width:15%;
    padding-top:5%;
    padding-bottom:5%;
}

.optandans{
    min-width:30%;
    max-width:30%;
    border:1px black solid;
    border-collapse:collapse;
}

.option{
    min-width:100%;
    max-width:100%;
    padding-top:5%;
    padding-bottom:5%;
}

.answer { 
    min-width:100%;
    max-width:100%;
    padding-top:5%;
    padding-bottom:5%;
     }   

.tblbody{
    background-color: #ddd;
    height: 400px;
    overflow: auto; 
}

.tblhead, .tblbody {
    display: block;
}
  • 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-06-16T07:08:35+00:00Added an answer on June 16, 2026 at 7:08 am

    The result
    enter image description here

    with the following CSS

    <style type="text/css">
            .qid {
                width:15%;
            }
    
            .question {
                width:30%;
            }
    
            .extratd {
                /*
                 * width will be the remaining of its parent.
                 */
            }
            table {
                border-collapse:collapse;
            }
            td, th {
                border:1px solid black;
                /*
                 * In case the long word will affect the width of TD
                 */
                word-wrap:break-word;
                word-break:break-all;
            }
            thead {
                /*
                 * minus the scollbar's width from THEAD
                 */
                margin-right:12px;
            }
            thead, tbody {
                /*
                 * Override the default display table-head-group, table-row-group.
                 * If not, the height will be computed with table layout rendering algorithm
                 * by browser
                 */
                display:block;
            }
            tbody {
                /*
                 * let the TABLE BODY part scroll
                 */
                height:400px;
                overflow:scroll;
            }
            tbody td {
                /* In case the children in the TD will change its width which 
                 * set by CSS implicitly, such as 15%, 30%
                 */
                overflow:hidden;
            }
            textarea {
                /* to override the default width of text area in case it will 
                 * go out of TD */
                width:100%;
            }
        </style>
    

    See the comments inline. There is a problem for this solution, we have to know the width of scroll bar, so the compatibility won’t be good.

    <table>
            <thead>
                <tr>
                    <th class="qid">Question No</th>
                    <th class="question">Question</th>
                    <th class="extratd">Option and Answer</th>
                </tr>
            </thead>
            <tbody>
                <tr align="center" class="optionAndAnswer">
                    <td class="qid">1</td>
                    <td class="question">                   
                        <textarea class="textAreaQuestion" name="questionText[]" value=""></textarea>
                    </td>
                    <td class="extratd">
                    <div class="option">
                        1. Option Type:
                        <br>
                        <input type="text" readonly="readonly" class="gridTxtRow maxRow" name="gridValues[]" value="">
                        <span class="showGrid" href="#">[Open Grid]</span>
                    </div>
                    <div class="noofanswers">
                        2. Number of Answers:
                        <br>
                        <span style="display: none;" class="naRow string" name="numberAnswer[]" value="">Only 1 Answer</span>
                        <input type="text" onchange="getButtons()" onkeypress="return isNumberKey(event)" onkeyup="numberKeyUp(this)" style="display: block;" class="numberAnswerTxtRow answertxt" name="numberAnswer[]" value="">
                    </div>
                    <div class="answer">
                        3. Answer:
                        <br>
                    </div>
                    </td>
                </tr>
            </tbody>
        </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv
I'm attempting to create a Google 2 Factor Authorisation just as an experiment not
I'm attempting to create a single Controller class to handle all foreseeable surveys that
I'm attempting to create a modal on a form that calls a CFC to
I'm attempting to create a column in css that is 100% height of the
I'm attempting to create an array of strings that represent the directories stored in
I'm attempting to create an ASP.NET/C# page that runs a PowerShell script that will
I am attempting to create a report that contains a list nested within another
I'm attempting to create a function where I can pass names and values that

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.