...对不起我的英语
这是我的页面的示例。我有一个固定布局、100% 宽度和一列“尽可能宽”的表格。按钮正在添加列。当我拉伸页面宽度时,一切正常。但是当我添加列并将结果区域拉伸到更小的宽度时,列“2”变得越来越小到零。我可以解决这个问题吗?
代码:
HTML:
<table>
<thead>
<tr>
<th class="short">1</th>
<th>2</th>
<th class="long">3</th>
</tr>
</thead>
<tr>
<td>dummy dummy dummy dummy </td>
<td>dummy dummy dummy dummy dummy </td>
<td>dummy dummy dummy dummy dummy </td>
</tr>
<tr>
<td>dummy dummy dummy dummy </td>
<td>dummy dummy dummy dummy dummy </td>
<td>dummy dummy dummy dummy dummy </td>
</tr>
CSS:
table{
table-layout:fixed;
width:100%;
min-width:200px;
}
td,th{
border:1px solid black;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.short{
width: 50px;
}
.long{
width: 100px;
}
JS:
$('document').ready(function(){
$('#addCol').click(function(){
var c = $("table thead th").length;
$("table thead tr").append("<th class=\"long\">" + (c+1) + "</th>");
$("table tr:gt(0)").append("<td>dummy dummy dummy dummy dummy </td>");
});
});
谢谢!