代码之家  ›  专栏  ›  技术社区  ›  Abu Ayyub

悬停时显示表格行边框

  •  0
  • Abu Ayyub  · 技术社区  · 6 年前

    我使用一个DIV表,但是当我设置 悬停 在第行,它不工作,标题/ .西亚德 没关系,但是在 .t车身 它不工作,只显示悬停 左边框 , 右边框 下边框 ,我忘记什么了吗?如何解决?这是我的代码:

    .divTable {
      display: table;
      width: 100%;
      border-collapse: collapse;
      border-spacing: 0 5px;
    }
    
    .divTable .tr {
      display: table-row;
    }
    
    .divTable .thead {
      display: table-header-group;
    }
    
    .divTable .td,
    .th {
      display: table-cell;
      padding: 3px 10px;
    }
    
    .divTable .thead {
      display: table-header-group;
      font-weight: bold;
    }
    
    .divTable .tfoot {
      display: table-footer-group;
      font-weight: bold;
    }
    
    .divTable .tbody {
      display: table-row-group;
    }
    
    .divTable {
      font-size: 12px;
      cursor: default;
      width: 100%;
    }
    
    .divTable .th,
    .divTable .td {
      padding: 4px 6px;
    }
    
    .divTable .tr {
      border: 1px solid white;
      height: 26px;
    }
    
    .divTable .tr:hover {
      background-color: rgba(162, 216, 242, 0.14);
      border: 1px solid rgba(124, 204, 243, 0.58);
      border-top: 1px solid rgba(124, 204, 243, 0.58);
      height: 26px;
    }
    <div class="divTable">
      <div class="thead">
        <div class="tr">
          <div class="th">Filename</div>
          <div class="th">Type</div>
          <div class="th">Size</div>
        </div>
      </div>
      <div class="tbody">
        <div class="tr">
          <div class="td">Why Cannot Work.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
        <div class="tr">
          <div class="td">Lorem Ipsum.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
        <div class="tr">
          <div class="td">Dolor Sir Amet.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
      </div>
    </div>
    3 回复  |  直到 6 年前
        1
  •  1
  •   Nisarg Shah    6 年前

    border-collapse

    .td :first-child :last-child

    .divTable .tr:hover .td {
      border-top: 1px solid rgba(124, 204, 243, 0.58);
      border-bottom: 1px solid rgba(124, 204, 243, 0.58);
    }
    
    .divTable .tr:hover .td:first-child {
      border-left: 1px solid rgba(124, 204, 243, 0.58);
    }
    
    .divTable .tr:hover .td:last-child {
      border-right: 1px solid rgba(124, 204, 243, 0.58);
    }
    

    .divTable {
      display: table;
      width: 100%;
      border-collapse: collapse;
      border-spacing: 0 5px;
    }
    
    .divTable .tr {
      display: table-row;
    }
    
    .divTable .thead {
      display: table-header-group;
    }
    
    .divTable .td,
    .th {
      display: table-cell;
      padding: 3px 10px;
    }
    
    .divTable .thead {
      display: table-header-group;
      font-weight: bold;
    }
    
    .divTable .tfoot {
      display: table-footer-group;
      font-weight: bold;
    }
    
    .divTable .tbody {
      display: table-row-group;
    }
    
    .divTable {
      font-size: 12px;
      cursor: default;
      width: 100%;
    }
    
    .divTable .th,
    .divTable .td {
      padding: 4px 6px;
    }
    
    .divTable .tr {
      border: 1px solid white;
      height: 26px;
    }
    
    .divTable .tr:hover {
      background-color: rgba(162, 216, 242, 0.14);
      border: 1px solid rgba(124, 204, 243, 0.58);
      height: 26px;
    }
    
    .divTable .tr:hover .td {
      border-top: 1px solid rgba(124, 204, 243, 0.58);
      border-bottom: 1px solid rgba(124, 204, 243, 0.58);
    }
    
    .divTable .tr:hover .td:first-child {
      border-left: 1px solid rgba(124, 204, 243, 0.58);
    }
    .divTable .tr:hover .td:last-child {
      border-right: 1px solid rgba(124, 204, 243, 0.58);
    }
    <div class="divTable">
      <div class="thead">
        <div class="tr">
          <div class="th">Filename</div>
          <div class="th">Type</div>
          <div class="th">Size</div>
        </div>
      </div>
      <div class="tbody">
        <div class="tr">
          <div class="td">Why Cannot Work.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
        <div class="tr">
          <div class="td">Lorem Ipsum.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
        <div class="tr">
          <div class="td">Dolor Sir Amet.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
      </div>
    </div>
        2
  •  1
  •   goteee    6 年前

    .divTable {
      display: table;
      width: 100%;
      border-collapse: collapse;
      border-spacing: 0 5px;
      border: 1px solid transparent;
    }
    
    .divTable .tr {
      display: table-row;
    }
    
    .divTable .thead {
      display: table-header-group;
    }
    
    .divTable .td,
    .th {
      display: table-cell;
      padding: 3px 10px;
    }
    
    .divTable .thead {
      display: table-header-group;
      font-weight: bold;
    }
    
    .divTable .tfoot {
      display: table-footer-group;
      font-weight: bold;
    }
    
    .divTable .tbody {
      display: table-row-group;
    }
    
    .divTable {
      font-size: 12px;
      cursor: default;
      width: 100%;
    }
    
    .divTable .th,
    .divTable .td {
      padding: 4px 6px;
    }
    
    .divTable .tr {
      height: 26px;
    }
    
    .divTable .tr:hover {
      background-color: rgba(162, 216, 242, 0.14);
      border: 1px solid rgba(124, 204, 243, 0.58);
      border-top: 1px solid rgba(124, 204, 243, 0.58);
      height: 26px;
    }
    <div class="divTable">
      <div class="thead">
        <div class="tr">
          <div class="th">Filename</div>
          <div class="th">Type</div>
          <div class="th">Size</div>
        </div>
      </div>
      <div class="tbody">
        <div class="tr">
          <div class="td">Why Cannot Work.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
        <div class="tr">
          <div class="td">Lorem Ipsum.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
        <div class="tr">
          <div class="td">Dolor Sir Amet.jpg</div>
          <div class="td">Image</div>
          <div class="td">12.1 KB</div>
        </div>
      </div>
    </div>
        3
  •  0
  •   Sonam Ahuja    6 年前

    .divTable .tr {
     border: 1px solid white;