【问题标题】:jQuery sortable and draggable table keeping the CSS style while draggingjQuery 可排序和可拖动表格在拖动时保持 CSS 样式
【发布时间】:2014-08-12 17:18:13
【问题描述】:

在执行可排序或拖动移动时,我需要一些帮助来保持 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 上拖动一行时,该行失去了上边框。我该如何解决这个问题?

【问题讨论】:

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


    【解决方案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

    【讨论】:

    • 谢谢!!但是,现在行的边界不是 1px,而是 2px。明白我的意思吗?
    • @cafc:别忘了点我答案左边的勾号来接受答案,我发现你没有接受任何答案..!!
    • 抱歉,如果我将边框折叠从单独更改为折叠,半径边框表会消失...我需要保留半径边框
    • @cafc: 对不起,伙计,找不到该部分的解决方案,我会检查并更新
    • 好的,谢谢!也许解决方案是在拖动移动事件期间放置边框顶部....但我现在不这样做..或者是否有更简单的方法...
    猜你喜欢
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 2011-12-11
    • 2018-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多