|
|
Рядок 17: |
Рядок 17: |
| | | |
| ---- | | ---- |
− | <div id="container"><table border="1" cellpadding="2" cellspacing="1" width="80%">
| |
− | <thead>
| |
− | <tr bgcolor="#cccccc">
| |
− | <td>head 1</td><td>head 2</td><td>head 3</td><td>head 4</td><td>head 5</td>
| |
− | </tr>
| |
− | </thead>
| |
− | <tbody>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | <tr><td>1</td><td>22</td><td>333</td><td>4444</td><td>55555</td></tr>
| |
− | </tbody>
| |
− | <tfoot>
| |
− | <tr bgcolor="#f5f5f5">
| |
− | <td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
| |
− | </tr>
| |
− | </tfoot>
| |
− | </table>
| |
− | </div>
| |
− | <script type="text/javascript">
| |
− | var c = document.getElementById('container');
| |
− | var t = c.firstChild;
| |
− | var tH = t.tHead;
| |
− | var tB = t.tBodies[0];
| |
− | var tF = t.tFoot;
| |
− | var len = t.rows[0].cells.length;
| |
− |
| |
− | for(var i = 0; i < len; i++){
| |
− | var w = tH.rows[0].cells[i].offsetWidth + t.cellPadding*2 + "px";
| |
− | tH.rows[0].cells[i].style.width =
| |
− | tB.rows[0].cells[i].style.width =
| |
− | tF.rows[0].cells[i].style.width = w;
| |
− | }
| |
− | t.style.width = (t.offsetWidth + t.cellPadding*len) + "px";
| |
− |
| |
− | var header = t.cloneNode(false);
| |
− | header.appendChild(tH);
| |
− | c.parentNode.insertBefore(header, c);
| |
− |
| |
− | var footer = t.cloneNode(false);
| |
− | footer.appendChild(tF);
| |
− | c.parentNode.insertBefore(footer, c.nextSibling);
| |
− |
| |
− | c.style.height = "200px";
| |
− | c.style.overflow = "auto";
| |
− | c.style.width = (c.offsetWidth - c.clientWidth) + t.offsetWidth + "px"
| |
− | </script>
| |