Halli Hallo,
bitte bitte nicht vor der Länge des Codes erschrecken, (ist lang (aber viel nur zu Testzwecken))
Mein Problem: wenn ich nach links und wieder in der tabelle scrolle so scrollt nur der tbody aber nicht der thead...warum???
ich würde auch gern nur den vertikalen Scrollbar der Tabelle sehen und nicht den unteren der Seite.
der thead sollte dann quasi abgeschnitten sein und nur angezeigt werden wenn nach rechts gescrollt wird
Danke schonmal
PS: ich weiss das ganze funktioniert wenn man's im Quirksmode laufen lässt (ohne DOCTYPE) das ist aber keine Lösung für mich
Code:
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function changecss(theClass,element,value) {
var cssRules;
if (document.styleSheets[0]['rules']) {
cssRules = 'rules';
}
else {
cssRules = 'cssRules';
}
theClass = theClass.toLowerCase();
for (var S = 0; S < document.styleSheets.length; S++){
for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
var seltxt = document.styleSheets[S][cssRules][R].selectorText;
if(seltxt) seltxt = seltxt.toLowerCase();
//alert(seltxt + "=" + theClass);
if (seltxt == theClass) {
document.styleSheets[S][cssRules][R].style[element] = value;
}
}
}
}
function get_document_height() {
if(window.innerHeight) return window.innerHeight;
if(document.documentElement.clientHeight) return document.documentElement.clientHeight;
return null;
}
function get_document_width() {
if(window.innerWidth) return window.innerWidth;
if(document.documentElement.clientWidth) return document.documentElement.clientWidth;
return null;
}
function onload(){
var base_height = (get_document_height() - 40);
changecss("div.tableContainer", "height", base_height + "px");
}
</script>
<style type="text/css">
div.tableContainer {
background-color: #F7F7F7;
width: 100%; /* table width will be 99% of this*/
height: 100%; /* must be greater than tbody*/
overflow: auto;
}
table {
width: 100%;
border: none;
background-color: #f7f7f7;
}
/*
* Specific Firefox. Only Modern browser are able to interpret > . IE is not a modern browser
*/
table>tbody {
overflow: hidden;
overflow-x: hidden;
}
/*
* Traget is IE5+ only. Only IE is able to interpret this kind of horrible expression Script
* ----------
* FOR HEADER
*/
thead tr {
position:relative;
top: expression(offsetParent.scrollTop);
}
/*
* Classical Css
*/
thead td, thead th {
text-align: left;
font-size: 14px;
background-color: #fdf5e6;
color: steelblue;
font-weight: bold;
border-top: solid 1px #d8d8d8;
background-image: url(../images/small.gif);
background-repeat: no-repeat;
background-position: right;
cursor: pointer;
padding-right: 15px;
}
td {
color: #000;
padding-right: 2px;
font-size: 12px;
text-align: right;
border-bottom: solid 1px #d8d8d8;
border-left: solid 1px #d8d8d8;
white-space: nowrap;
}
/*
* FF scroll hide last column.
* prevent this case
*/
td:last-child {
padding-right: 20px;
}
</style>
</head>
<body onLoad="onload();">
<div class="tableContainer">
<table cellspacing="0">
<thead>
<tr>
<td>Header cell1</td>
<td>Header cell2</td>
<td>Header cell3</td>
<td>Header cell 4</td>
</tr>
</thead>
<tbody>
<tr>
<td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td>
<td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td>
<td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td>
<td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>z</td>
<td>z</td>
<td>z</td>
<td>z</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
Alles anzeigen
[/code]