Now after two years, I am able to find something which works fine in Firefox as well as Chrome. Most difficult part was making the table scrollable in Chrome, FF and IE. (Only one dimensional scroll works in Firefox and Chrome, that means only fixed header and fixed footer not fix columns)
Now how to make Scrollable table in Chrome.
- Copy this code and modify it to suite your requirements.
- What ever highlighted in bold are important ones. Specify height and width for DIV.
- Height for tbody should be less than Div width(Div width -100px)
I guess you want to know what is difference between present code which works fine in Chrome and Firefox and past code which only works fine in IE.
Here I have used HTML tags which changes the style sheet according to browser. The below code works only when browser is other than IE.
These CSS are regarded as CSS hacks, but they are still safe to to use. You can check this website http://www.webdevout.net/css-hacks for more information.
html>body div.tableHolder {
overflow: hidden;
}
html>body tbody.scrollBody {
height: 200px;
overflow: auto;
}
The code for IE is same. But for Firefox and Chrome what I am doing is; I am making TBODY scrollable by setting Overflow:auto
But if we make TBODY scrollable, there is one problem with the last column. It will have different width. And it will behave differently when used in FF and Chrome. So I have added extra cell for header and footer by using the below code.
<!--[if !IE]><!-->
<td widtd="16px" style="background-color:#ffffff; visibility: hidden"> </td>
<!--<![endif]-->
If the browser is not IE then it will add a extra cell to header. and Similar code is kept in footer to do the same thing.
I don't have much knowledge on browser, but few things were not working fine in Chrome. So kept Javascript which will detect Chrome browser and change the properties accordingly.
<script>
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome')> -1;
if(isChrome){
document.getElementById('scrollHead').style.display ="block";
document.getElementById('scrollBody').style.display ="block";
document.getElementById('scrollFooter').style.display ="block";
document.getElementById('tableHolder2').style.width ="580px";
}
</script>
Rest of the code is explained in the my previous post.
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column | |
first-column | second | second | second | second | second | second | second | second | Last-column |