dynamic table and keep the thead fixed
up vote
1
down vote
favorite
I have a dynamic table and I want to keep its head fixed when I scroll the table.
The table is as follows.What this basically does is, javascript will use the number in the input field and create any number of rows as it includes.I have used a fixed height for the table.But when the table grows more than the height given then I have to scroll to go down.Then the thead also goes up and go invisible, so any method to fix the thead is appreciated.
Note : I have gone through almost all the stuff here related to the same topic, but it doesnot seem to work for me.
HTML
<div class="container-fluid"" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
JAVASCRIPT
function addRow(){
var rowcount = document.getElementById('rowcount').value;
var table = document.getElementById('tableAddResults');
for(y=0;y<rowcount;y++){
var newrow = table.insertRow();
var cell0 = newrow.insertCell(0);
var cell0Text = document.createTextNode('AT-');
cell0.appendChild(cell0Text);
cell0.setAttribute('contentEditable','true');
for(i=1;i<4;i++){
var cell = newrow.insertCell(i);
var cellText = document.createTextNode('');
cell.appendChild(cellText);
cell.setAttribute('contentEditable','true');
}
}
};
The CSS code I used is given below.
div.container-fluid{
overflow:hidden;
overflow-y: scroll;
height: 450px;
}
javascript html css
New contributor
add a comment |
up vote
1
down vote
favorite
I have a dynamic table and I want to keep its head fixed when I scroll the table.
The table is as follows.What this basically does is, javascript will use the number in the input field and create any number of rows as it includes.I have used a fixed height for the table.But when the table grows more than the height given then I have to scroll to go down.Then the thead also goes up and go invisible, so any method to fix the thead is appreciated.
Note : I have gone through almost all the stuff here related to the same topic, but it doesnot seem to work for me.
HTML
<div class="container-fluid"" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
JAVASCRIPT
function addRow(){
var rowcount = document.getElementById('rowcount').value;
var table = document.getElementById('tableAddResults');
for(y=0;y<rowcount;y++){
var newrow = table.insertRow();
var cell0 = newrow.insertCell(0);
var cell0Text = document.createTextNode('AT-');
cell0.appendChild(cell0Text);
cell0.setAttribute('contentEditable','true');
for(i=1;i<4;i++){
var cell = newrow.insertCell(i);
var cellText = document.createTextNode('');
cell.appendChild(cellText);
cell.setAttribute('contentEditable','true');
}
}
};
The CSS code I used is given below.
div.container-fluid{
overflow:hidden;
overflow-y: scroll;
height: 450px;
}
javascript html css
New contributor
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a dynamic table and I want to keep its head fixed when I scroll the table.
The table is as follows.What this basically does is, javascript will use the number in the input field and create any number of rows as it includes.I have used a fixed height for the table.But when the table grows more than the height given then I have to scroll to go down.Then the thead also goes up and go invisible, so any method to fix the thead is appreciated.
Note : I have gone through almost all the stuff here related to the same topic, but it doesnot seem to work for me.
HTML
<div class="container-fluid"" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
JAVASCRIPT
function addRow(){
var rowcount = document.getElementById('rowcount').value;
var table = document.getElementById('tableAddResults');
for(y=0;y<rowcount;y++){
var newrow = table.insertRow();
var cell0 = newrow.insertCell(0);
var cell0Text = document.createTextNode('AT-');
cell0.appendChild(cell0Text);
cell0.setAttribute('contentEditable','true');
for(i=1;i<4;i++){
var cell = newrow.insertCell(i);
var cellText = document.createTextNode('');
cell.appendChild(cellText);
cell.setAttribute('contentEditable','true');
}
}
};
The CSS code I used is given below.
div.container-fluid{
overflow:hidden;
overflow-y: scroll;
height: 450px;
}
javascript html css
New contributor
I have a dynamic table and I want to keep its head fixed when I scroll the table.
The table is as follows.What this basically does is, javascript will use the number in the input field and create any number of rows as it includes.I have used a fixed height for the table.But when the table grows more than the height given then I have to scroll to go down.Then the thead also goes up and go invisible, so any method to fix the thead is appreciated.
Note : I have gone through almost all the stuff here related to the same topic, but it doesnot seem to work for me.
HTML
<div class="container-fluid"" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
JAVASCRIPT
function addRow(){
var rowcount = document.getElementById('rowcount').value;
var table = document.getElementById('tableAddResults');
for(y=0;y<rowcount;y++){
var newrow = table.insertRow();
var cell0 = newrow.insertCell(0);
var cell0Text = document.createTextNode('AT-');
cell0.appendChild(cell0Text);
cell0.setAttribute('contentEditable','true');
for(i=1;i<4;i++){
var cell = newrow.insertCell(i);
var cellText = document.createTextNode('');
cell.appendChild(cellText);
cell.setAttribute('contentEditable','true');
}
}
};
The CSS code I used is given below.
div.container-fluid{
overflow:hidden;
overflow-y: scroll;
height: 450px;
}
javascript html css
javascript html css
New contributor
New contributor
New contributor
asked Nov 10 at 17:56
PrabodD.
61
61
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
You can do this purly with css using position: sticky like the following. You can then change top
to tell it how far it needs to be from the top to start becoming sticky.
A stickily positioned element is an element whose computed position value is sticky. It's treated as relatively positioned until its containing block crosses a specified threshold (such as setting top to value other than auto) within its flow root (or the container it scrolls within), at which point it is treated as "stuck" until meeting the opposite edge of its containing block.
thead > tr > th {
position: sticky;
top: 0;
background: white;
}
table {width: 100%;}
<div class="container-fluid" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
</tbody>
</table>
</div>
it does the job, but it make the head transparent
– PrabodD.
Nov 10 at 18:03
I fixed that, with just some basic css
– Get Off My Lawn
Nov 10 at 18:04
that works fine
– PrabodD.
Nov 10 at 18:05
What is the meaning of thead > tr > th
– PrabodD.
Nov 11 at 2:40
The>
Means that the next item must be a direct child. Sotr
must be a direct child ofthead
andth
must be a direct child oftr
. developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors
– Get Off My Lawn
Nov 11 at 18:52
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You can do this purly with css using position: sticky like the following. You can then change top
to tell it how far it needs to be from the top to start becoming sticky.
A stickily positioned element is an element whose computed position value is sticky. It's treated as relatively positioned until its containing block crosses a specified threshold (such as setting top to value other than auto) within its flow root (or the container it scrolls within), at which point it is treated as "stuck" until meeting the opposite edge of its containing block.
thead > tr > th {
position: sticky;
top: 0;
background: white;
}
table {width: 100%;}
<div class="container-fluid" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
</tbody>
</table>
</div>
it does the job, but it make the head transparent
– PrabodD.
Nov 10 at 18:03
I fixed that, with just some basic css
– Get Off My Lawn
Nov 10 at 18:04
that works fine
– PrabodD.
Nov 10 at 18:05
What is the meaning of thead > tr > th
– PrabodD.
Nov 11 at 2:40
The>
Means that the next item must be a direct child. Sotr
must be a direct child ofthead
andth
must be a direct child oftr
. developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors
– Get Off My Lawn
Nov 11 at 18:52
add a comment |
up vote
1
down vote
You can do this purly with css using position: sticky like the following. You can then change top
to tell it how far it needs to be from the top to start becoming sticky.
A stickily positioned element is an element whose computed position value is sticky. It's treated as relatively positioned until its containing block crosses a specified threshold (such as setting top to value other than auto) within its flow root (or the container it scrolls within), at which point it is treated as "stuck" until meeting the opposite edge of its containing block.
thead > tr > th {
position: sticky;
top: 0;
background: white;
}
table {width: 100%;}
<div class="container-fluid" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
</tbody>
</table>
</div>
it does the job, but it make the head transparent
– PrabodD.
Nov 10 at 18:03
I fixed that, with just some basic css
– Get Off My Lawn
Nov 10 at 18:04
that works fine
– PrabodD.
Nov 10 at 18:05
What is the meaning of thead > tr > th
– PrabodD.
Nov 11 at 2:40
The>
Means that the next item must be a direct child. Sotr
must be a direct child ofthead
andth
must be a direct child oftr
. developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors
– Get Off My Lawn
Nov 11 at 18:52
add a comment |
up vote
1
down vote
up vote
1
down vote
You can do this purly with css using position: sticky like the following. You can then change top
to tell it how far it needs to be from the top to start becoming sticky.
A stickily positioned element is an element whose computed position value is sticky. It's treated as relatively positioned until its containing block crosses a specified threshold (such as setting top to value other than auto) within its flow root (or the container it scrolls within), at which point it is treated as "stuck" until meeting the opposite edge of its containing block.
thead > tr > th {
position: sticky;
top: 0;
background: white;
}
table {width: 100%;}
<div class="container-fluid" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
</tbody>
</table>
</div>
You can do this purly with css using position: sticky like the following. You can then change top
to tell it how far it needs to be from the top to start becoming sticky.
A stickily positioned element is an element whose computed position value is sticky. It's treated as relatively positioned until its containing block crosses a specified threshold (such as setting top to value other than auto) within its flow root (or the container it scrolls within), at which point it is treated as "stuck" until meeting the opposite edge of its containing block.
thead > tr > th {
position: sticky;
top: 0;
background: white;
}
table {width: 100%;}
<div class="container-fluid" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
</tbody>
</table>
</div>
thead > tr > th {
position: sticky;
top: 0;
background: white;
}
table {width: 100%;}
<div class="container-fluid" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
</tbody>
</table>
</div>
thead > tr > th {
position: sticky;
top: 0;
background: white;
}
table {width: 100%;}
<div class="container-fluid" style="width: 90%" style="height: 90%">
<table id="tableAddResults" class="table table-hover" cellspacing="0">
<thead>
<tr>
<th scope="col">Index No</th>
<th scope="col">Correct A</th>
<th scope="col">Incorrect A</th>
<th scope="col">Total A</th>
</tr>
</thead>
<tbody>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
<tr><td>test</td><td>test</td><td>test</td><td>test</td></tr>
</tbody>
</table>
</div>
edited Nov 10 at 18:06
answered Nov 10 at 18:01
Get Off My Lawn
12.8k1676162
12.8k1676162
it does the job, but it make the head transparent
– PrabodD.
Nov 10 at 18:03
I fixed that, with just some basic css
– Get Off My Lawn
Nov 10 at 18:04
that works fine
– PrabodD.
Nov 10 at 18:05
What is the meaning of thead > tr > th
– PrabodD.
Nov 11 at 2:40
The>
Means that the next item must be a direct child. Sotr
must be a direct child ofthead
andth
must be a direct child oftr
. developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors
– Get Off My Lawn
Nov 11 at 18:52
add a comment |
it does the job, but it make the head transparent
– PrabodD.
Nov 10 at 18:03
I fixed that, with just some basic css
– Get Off My Lawn
Nov 10 at 18:04
that works fine
– PrabodD.
Nov 10 at 18:05
What is the meaning of thead > tr > th
– PrabodD.
Nov 11 at 2:40
The>
Means that the next item must be a direct child. Sotr
must be a direct child ofthead
andth
must be a direct child oftr
. developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors
– Get Off My Lawn
Nov 11 at 18:52
it does the job, but it make the head transparent
– PrabodD.
Nov 10 at 18:03
it does the job, but it make the head transparent
– PrabodD.
Nov 10 at 18:03
I fixed that, with just some basic css
– Get Off My Lawn
Nov 10 at 18:04
I fixed that, with just some basic css
– Get Off My Lawn
Nov 10 at 18:04
that works fine
– PrabodD.
Nov 10 at 18:05
that works fine
– PrabodD.
Nov 10 at 18:05
What is the meaning of thead > tr > th
– PrabodD.
Nov 11 at 2:40
What is the meaning of thead > tr > th
– PrabodD.
Nov 11 at 2:40
The
>
Means that the next item must be a direct child. So tr
must be a direct child of thead
and th
must be a direct child of tr
. developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors– Get Off My Lawn
Nov 11 at 18:52
The
>
Means that the next item must be a direct child. So tr
must be a direct child of thead
and th
must be a direct child of tr
. developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors– Get Off My Lawn
Nov 11 at 18:52
add a comment |
PrabodD. is a new contributor. Be nice, and check out our Code of Conduct.
PrabodD. is a new contributor. Be nice, and check out our Code of Conduct.
PrabodD. is a new contributor. Be nice, and check out our Code of Conduct.
PrabodD. is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241840%2fdynamic-table-and-keep-the-thead-fixed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown