jQuery 可排序和可拖动表格在拖动时保持 CSS 样式

标签 jquery css draggable jquery-ui-sortable css-tables

我需要一些帮助来在执行可排序或拖动移动时保持 CSS 样式(td 宽度等)。

到目前为止我的代码:

JSFiddle

CSS:

body {
  margin: 30px;
}
table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 350px;
}
table tr th,
table tr td {
  border-right: 1px solid #bbb;
  border-bottom: 1px solid #bbb;
  padding: 5px;
}
table tr th:first-child,
table tr td:first-child {
  border-left: 1px solid #bbb;
}
table tr th {
  background: #eee;
  border-top: 1px solid #bbb;
  text-align: left;
}

/* top-left border-radius */
table tr:first-child th:first-child {
  border-top-left-radius: 6px;
}

/* top-right border-radius */
table tr:first-child th:last-child {
  border-top-right-radius: 6px;
}

/* bottom-left border-radius */
table tr:last-child td:first-child {
  border-bottom-left-radius: 6px;
}

/* bottom-right border-radius */
table tr:last-child td:last-child {
  border-bottom-right-radius: 6px;
}

当我开始拖动表 1 上的一行时,该行失去了上边框。我该如何解决这个问题?

最佳答案

你也应该指定 border-top: 1px solid #bbb;,你只指定了 border-bottomborder-right只有

所以解决方法是

table tr th,
table tr td {
  border-right: 1px solid #bbb;
  border-bottom: 1px solid #bbb;
     border-top: 1px solid #bbb;
  padding: 5px;
}

DEMO

关于jQuery 可排序和可拖动表格在拖动时保持 CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25270296/

相关文章:

JavaScript 和 JSON 效率?我们应该制作一个更小的数组吗?

javascript - Javascript 中的事件传播

Javascript 本地与全局

css - 在 IE11 中调整 SVG 大小

c# - 使用数据库值从代码后面更改 css

css - 为什么我的过渡变换表现得很奇怪?

draggable - 将 Google Maps V3 标记的拖动限制到折线

Javascript:类属性在拖动事件期间变得未定义

javascript - 拖动它的 child 时如何避免拖动 parent ?

javascript - 如何用JavaScript控制多个音频播放器?