带有圆角的HTML / CSS表,javascript-border更改不起作用

时间:2017-11-01 11:52:26

标签: html css css3 less

我有一个圆角的桌子。 这个基本的CSS就是我在table-element上添加了类.table-bordered,如下所示:

 .table-bordered 
   {
     border: 1px solid @tableBorder;
     border-collapse: separate; 
    .border-radius(@baseBorderRadius);
  }

这很有效。 但是我们在javascript中实现了一个drag-function。可以将元素拖到表格行中。

要向用户显示他们拖动元素的行,我想在TR中添加一个虚线边框,如下所示:

tr.dropzone-active {
    border: 3px dashed darken(@portletBorderColor, 10%);
    .box-shadow(0 0 10px 0 rgba(0, 0, 0, .25));
    .scale(1.01);
}

因此,当我在TR上拖动文档时,我将类dropzone-active添加到TR以更改边框。 Box-shadow和.scale适用于此。但边界没有改变(3px和虚线)。 原因是table-css元素:

border-collapse: separate;

如果我删除它,拖放边框会改变,但是我的角落不会圆角。 有没有办法解决这个问题?

例如添加border-collapse:collapse到dropzone-active元素还是什么?

1 个答案:

答案 0 :(得分:0)

你的目标是这个效果吗?



.table {
  display:block;
  width: 100px;
  padding:20px;
  margin-top: 10px;
  margin-left:10px;
  margin-right:10px;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid black;
  border-radius: 6px;
  -moz-border-radius:6px;
  -webkit-border-radius:6px;
  border-style: hidden; /* hide standard table (collapsed) border */
  box-shadow: 0 0 0 1px #666; /* this draws the table border  */ 
}
tr.dropzone-active {
  border-style: dotted;
}
table tr th,
table tr td {
  border-right: 1px dotted #bbb;
  border-bottom: 1px dotted #bbb;
  border-left: 1px dotted #bbb;
  padding: 5px;
}
/* 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;
}
table tr th:first-child,
table tr td:first-child {
  border-left: 1px solid #bbb;
}

<table class="table">
<thead>
  <tr class="dropzone-active">
    <th>1</th>
    <th>2</th>
  </tr>
</thead>
<tbody>
  <tr>
    <td>fname</td>
    <td>lname</td>
  </tr>
  
</tbody>
</table>
&#13;
&#13;
&#13;