[英]jQuery Sortable collapses table border on sort
I found this jsfiddle on another SO thread with similar code that I have and can reproduce the behavior. 我在另一个具有类似代码的SO线程上找到了这个jsfiddle,并且可以重现此行为。 http://jsfiddle.net/LMqNH/74/
http://jsfiddle.net/LMqNH/74/
You'll see that the table has a 3px red border. 您会看到表格有3px的红色边框。 When you drag to sort a row, you'll notice that the red bottom-border gets cut off and only goes as far as the first column.
拖动以对行进行排序时,您会注意到红色的底部边框被切除,仅到达第一列。
Here's the code 这是代码
sortHelper = function(e, el) {
var $orig = el.children();
var $hlp = el.clone();
$hlp.children().each(function(index) {
$(this).width($orig.eq(index).width());
});
return $hlp;
};
$('tbody').sortable({
helper: sortHelper
}).disableSelection();
I found a little workaround to solving the issue. 我找到了解决此问题的一些解决方法。 I just made a div wrapper to go around the table with the border you desire, and it works fine.
我只是做了一个div包装器,使表随心所欲地围在桌子上,效果很好。 Note that I made the width of the table to 100% for simplicity (you can alter the width of the table and wrapper as you need).
请注意,为简单起见,我将表格的宽度设置为100%(您可以根据需要更改表格和包装纸的宽度)。
HTML HTML
<div class='table-wrapper'>
<table>
<thead>
<tr><th>A</th><th>B</th><th>C</th></tr>
</thead>
<tbody>
<tr sortOrder="1"><td>1</td><td class="sortOrder"></td><td>a</td></tr>
<tr sortOrder="2"><td>2</td><td class="sortOrder"></td><td>b</td></tr>
<tr sortOrder="3"><td>3</td><td class="sortOrder"></td><td>c</td></tr>
<tr sortOrder="4"><td>4</td><td class="sortOrder"></td><td>d</td></tr>
</tbody>
</table>
</div>
CSS CSS
table{
border-collapse:collapse;
/*above is problem in chrome and safari.
IE, FF, Opera seem ok*/
margin:auto; width:100%; font-family:sans-serif; font-weight:bolder; cursor:default;}
th{background-color:#444;color:#aaa;padding:15px;text-align:center;}
td{background-color:#a60;color:#222;border:2px solid #fa0;padding:15px;text- align:center;}
tbody tr:hover td{background-color:#af6;border-color:#6a0;}
.table-wrapper{
border: 3px solid #f03 !important;
width:auto;
padding:0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.