UPDATED:
JavaScript:
Code:
<script type="text/javascript">
$(document).ready(function(){
firstColumn = $(".firstColumn");
maxWidth = 50;
// Get width % ratio for min width
var c_count = $('tr:first-child').children().size();
var w_ratio = (100 / c_count);
minWidth = w_ratio;
$("tr th").click(function(){
$(firstColumn).animate({
width: minWidth + "%"
}, {
queue: false,
duration: 900
});
$(this).animate({
width: maxWidth + "%"
}, {
queue: false,
duration: 900
});
firstColumn = this;
// Reset the cell width
$('tr:first-child').children().css({
'width': w_ratio,
'overflow': 'hidden',
'white-space': 'nowrap',
'text-overflow': 'ellipsis'
});
});
});
</script>
CSS:
Code:
<style type="text/css">
.tbl {
table-layout: fixed;
border-top: 5px solid #333;
border-collapse: collapse;
background: #fff;
} .tbl td {
border: 1px solid #688;
padding: 2px 5px;
overflow: hidden;
white-space: nowrap;
text-align: center;
} .tbl th {
border-bottom: 1px solid #333;
padding: 2px 5px;
overflow: hidden;
white-space: nowrap;
background: blue;
}
</style>
HTML:
HTML Code:
<table class="tbl" width="100%">
<tr>
<th class="firstColumn">
Cell 1:Heading
</th>
<th>
Cell 2:Long Heading Data
</th>
<th>
Cell 3:Heading
</th>
<th>
Cell 4:Heading
</th>
<th>
Cell 5:Heading
</th>
<th>
Cell 6:Heading
</th>
<th>
Cell 7:Heading
</th>
<th>
Cell 8:Heading
</th>
<th>
Cell 9:Heading
</th>
<th>
Cell 10:Heading
</th>
<th>
Cell 11:Heading
</th>
<th>
Cell 12:Heading
</th>
<th>
Cell 13:Heading
</th>
<th>
Cell 14:Heading
</th>
<th>
Cell 15:Heading
</th>
<th>
Cell 16:Heading
</th>
<th>
Cell 17:Heading
</th>
<th>
Cell 18:Heading
</th>
</tr>
<tr>
<td>
Cell 1:Row 1
</td>
<td>
Cell 2:Row 1:Overflowing Data
</td>
<td>
Cell 3:Row 1
</td>
<td>
Cell 4:Row 1
</td>
<td>
Cell 5:Row 1
</td>
<td>
Cell 6:Row 1
</td>
<td>
Cell 7:Row 1
</td>
<td>
Cell 8:Row 1
</td>
<td>
Cell 9:Row 1
</td>
<td>
Cell 10:Row 1
</td>
<td>
Cell 11:Row 1
</td>
<td>
Cell 12:Row 1
</td>
<td>
Cell 13:Row 1
</td>
<td>
Cell 14:Row 1
</td>
<td>
Cell 15:Row 1
</td>
<td>
Cell 16:Row 1
</td>
<td>
Cell 17:Row 1
</td>
<td>
Cell 18:Row 1
</td>
</tr>
<tr>
<td>
Cell 1:Row 2
</td>
<td>
Cell 2:Row 2:Overflowing Data
</td>
<td>
Cell 3:Row 2
</td>
<td>
Cell 4:Row 2
</td>
<td>
Cell 5:Row 2
</td>
<td>
Cell 6:Row 2
</td>
<td>
Cell 7:Row 2
</td>
<td>
Cell 8:Row 2
</td>
<td>
Cell 9:Row 2
</td>
<td>
Cell 10:Row 2
</td>
<td>
Cell 11:Row 2
</td>
<td>
Cell 12:Row 2
</td>
<td>
Cell 13:Row 2
</td>
<td>
Cell 14:Row 2
</td>
<td>
Cell 15:Row 2
</td>
<td>
Cell 16:Row 2
</td>
<td>
Cell 17:Row 2
</td>
<td>
Cell 18:Row 2
</td>
</tr>
</table>
Bookmarks