表列调整大小错误

问题描述 投票:0回答:1

我试图实现jQuery-UI插件来通过拖放来调整表列的大小。

我懂了:

$("#table,#table table tr th,#table table tr td").resizable({
     handles: 'e'
});

拖动工作正在改变大小,但在开始时我在两个表格列之间点击并稍微移动鼠标,列宽变得更大

我不知道如何解决这个问题......有什么想法吗?提前致谢

jquery jquery-ui jquery-ui-resizable
1个回答
0
投票

根据您的示例代码,请考虑以下示例。

$(function() {
  $("table").resizable();
  $("table thead th").resizable({
    handles: 'e'
  });
});
table {
  border-collapse: collapse;
}

table,
th,
td {
  border: 1px solid black;
}

table th {
  background: #CCC;
  width: 120px;
  min-width: 2em;
}

table thead tr .ui-resizable-e {
  border: 1px solid black;
  width: 2px;
  height: 17px;
  background: #666;
  top: 1px;
  right: -2px;
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<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>

<table>
  <thead>
    <tr>
      <th>H1</th>
      <th>H2</th>
      <th>H3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>A1</td>
      <td>B1</td>
      <td>C1</td>
    </tr>
    <tr>
      <td>A2</td>
      <td>B2</td>
      <td>C2</td>
    </tr>
    <tr>
      <td>A3</td>
      <td>B3</td>
      <td>C3</td>
    </tr>
  </tbody>
</table>

这允许用户调整标题的大小,并且通过表结构的代理,列的大小。

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.