i need to scroll the table body alone. all example says only with scrollbar. so, can i do scroll without scrollbar.just scroll up and down the table body. the scroll is only for table body.
it could be a css , JS or jQuery solution. I am clueless. So, helping hands plz…
Also, please use code tags when posting large amounts of code.
It makes your post considerably easier to read.
You can find them if you click “Go Advanced” in the “Syntax” drop down menu.
I am reposting this question in sitepoint under CSS. I need a CSS approach to scroll my table body without the apperance of scroll bar. Is it possible through CSS? If so, can i get an demostrated example and code. And i am also aiming at cross-browser compatability with all latest versions(firefox,safari,chrome,IE-8,9,10).
So, a couple of things are wrong with the code from post#2
First off, the closing </head> tag and the opening <body> tag are missing.
Also, the closing </div> tag after the table is missing.
For me, if I add those things, the document previews fine in IE9 standards mode.
To force IE9 into standards mode, you could just add:
Thanks. One more question, is there a JS or jQuery solution for scrolling tbody without scroll bar appearing or scroll appearing as needed after a min height of tbody . Searched a lot. Results are not apt. It would be great to have a solution.
I merged the threads as you asked the same question in the CSS forum. Please don’t repost the same question twice but ask for the thread to be moved if another forum is more suitable.
I’ve read through the thread but am a little unclear as to why you would want a scrollable table but not have a scrollbar? Users won’t know that they can scroll the table unless you provide the visual clue of the scrollbar. Unless you meant something else?
You can create a fixed header for a table and scroll the body and here is an example from years ago.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {margin:0 0 1em}
table p {margin :0}
.wrap {
margin:50px 0 0 2%;
width:95%;
float:left;
position:relative;
height:200px;
overflow:hidden;
padding:25px 0 0;
background:green;
border:1px solid #000;
}
.inner {
height:200px;
overflow:auto;
}
table {
width:100%;
margin:0 0 0 -1px;
border-collapse:collapse;
}
td {
padding:5px;
border:1px solid #000;
text-align:center;
background:yellow;
}
tfoot th, thead th {
font-weight:bold;
text-align:center;
border:1px solid #000;
padding:0 3px 0 5px;
background:green;
color:#fff;
}
thead th {border:none;}
thead tr p {
position:absolute;
top:3px;
}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.inner {overflow-x:hidden}
</style>
<![endif]-->
</head>
<body>
<h1>Table with fixed header in IE6 - 8, Firefox 2.+, Safari 3 and Opera 9.5+</h1>
<p>Notes: The header is part of the same table and not a separate table on top. The width of the table cells or header cells is not defined and will match whatever content is in the cells. The table can be a fluid length and will resize within reasonable limits accordingly.</p>
<div class="wrap">
<div class="inner">
<table id="data" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th><p>Jan</p></th>
<th><p>Feb</p></th>
<th><p>Mar</p></th>
<th><p>Apr</p></th>
<th><p>May</p></th>
<th><p>Jun</p></th>
<th><p>Jul</p></th>
<th><p>Aug</p></th>
<th><p>September</p></th>
<th><p>Oct</p></th>
<th><p>Nov</p></th>
<th><p>Dec</p></th>
</tr>
</thead>
<tfoot>
<tr>
<th><p>Jan</p></th>
<th><p>Feb</p></th>
<th><p>Mar</p></th>
<th><p>Apr</p></th>
<th><p>May</p></th>
<th><p>Jun</p></th>
<th><p>Jul</p></th>
<th><p>Aug</p></th>
<th><p>September</p></th>
<th><p>Oct</p></th>
<th><p>Nov</p></th>
<th><p>Dec</p></th>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>3</td>
<td>5</td>
<td>1</td>
<td>1</td>
<td>3</td>
<td>1</td>
<td>5</td>
<td>7</td>
<td>1</td>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>5</td>
<td>1</td>
<td>1</td>
<td>3</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>3 more data</td>
<td>5</td>
<td>7</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td>6</td>
<td>1</td>
<td>1</td>
<td>3</td>
<td>1</td>
<td>23</td>
<td>4</td>
<td>1</td>
<td>6</td>
<td>6</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>6</td>
<td>1</td>
<td>4</td>
<td>7</td>
<td>1</td>
<td>7</td>
<td>1</td>
<td>1</td>
<td>3</td>
<td>6</td>
</tr>
<tr>
<td>2</td>
<td>3 with more data</td>
<td>2</td>
<td>3</td>
<td>3</td>
<td>3</td>
<td>8</td>
<td>1</td>
<td>1</td>
<td>2</td>
<td>8</td>
<td>6</td>
</tr>
<tr>
<td>6</td>
<td>4</td>
<td>4</td>
<td>4</td>
<td>2</td>
<td>9</td>
<td>4</td>
<td>4</td>
<td>6</td>
<td>1</td>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>3</td>
<td>7</td>
<td>4</td>
<td>5</td>
<td>5</td>
<td>2</td>
<td>0</td>
<td>3</td>
<td>23</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>4</td>
<td>2</td>
<td>67</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>3</td>
<td>1</td>
<td>4</td>
<td>4</td>
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td>3</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>3</td>
<td>2</td>
<td>2</td>
<td>5</td>
<td>65</td>
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td>4</td>
<td>1</td>
<td>2</td>
<td>13</td>
<td>6</td>
<td>1</td>
<td>1</td>
<td>3</td>
<td>7</td>
<td>4</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
There are limitations to the styling of the header due to the method used to make this work but unlike other examples shown it works with variable width data.
To be fair to @Jesh, I suggested starting a new thread. I had however envisaged the OP taking the working code from above and reformulating their question more succinctly, as opposed to reposting the same one.[/ot]
Off topic just means that I wanted to add something to the discussion that was not directly related to your original question (i.e. an off topic comment).
It was not in regard to anything you did
I have tested this code and it works nicely. However how would you use it for a second table in the same html document that has different column widths and has a header that is two rows deep: i.e
Main Header(fixed)
h1 h2 h3(fixed)
col col col
col col col
I don’t seem to be able to define a second set of columns and headings
Thanks. It almost does what I need. I have existing Html see attachment that I am trying to replicate with a fixed header.
I need with this:
<th><div>
<p>May</p>
<p>more</p>
</div></th>
To have three separate headings for more so that the cells below map to these three sub headings (not the main heading), but have a main heading above these three like the attachment.