1、使用bootstrap美化表格,jquery UI的resizable()实现Table宽度可变。代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Default functionality</title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://resources/demos/style.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "th" ).resizable();
$( "td" ).resizable();
} );
</script>
</head>
<body>
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Resizable</h3>
<div>
<div>
<table id="tb" class="table table-bordered">
<tr>
<th>111</th>
<th>111</th>
<th>111</th>
</tr>
<tr>
<td>222</td>
<td>222</td>
<td>222</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>
2、使用jquery的colResizable控件
<head>
<script src="js/jquery.js"></script>
<script src="js/colResizable.min.js"></script>
<script>
$(function(){
$("table").colResizable();
});
</script>
</head>
<body>
<table width="100%" >
<tr> <th> header </th> <th> header </th> </tr>
<tr> <td> cell </td> <td> cell </td> </tr>
<tr> <td> cell </td> <td> cell </td> </tr>
</table>
</body>