如何在基于css的表的表行组体中添加滚动功能[已关闭]

7nbnzgx9  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(67)

**已关闭。**此问题需要debugging details。目前不接受回答。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答问题。
18小时前关闭
Improve this question
我试图创建这个:


的数据
我使用display: table属性和table-header-grouptable-row-grouptable-rowtable-cell css属性,而不是使用表标记。
当我将overflow-y: scroll添加到table-row-group时,没有任何变化,它激活了卡片的滚动。
我删除了溢出的卡,仍然不能使表的身体滚动。
为什么不能用table-row-group呢?
我创建了一个虚拟的jsfiddle,它看起来不同,但工作原理相同,你可以看到文本溢出外面。

0s7z1bwu

0s7z1bwu1#

我看了你的代码,问题是overflow-y样式必须添加到**.cardclass而不是.bodyclass。这是因为你想在div上滚动.card**class。你可以在下面看到正确的样式。

.card {
    width: 400px;
    height: 400px;
    background: black;
    box-sizing: border-box;
    color: white;
    overflow-y: scroll;
  
    padding: 16px;
  
    .container {
      width: 100%;
      display: table;
      border-spacing: 8px;
      border-collapse: collapse;
  
      .header {
        color: var(--neutrals-70);
        display: table-header-group;
  
        .row {
          display: table-row;
          border-bottom: solid 1px var(--neutrals-40);
  
          .cell {
            display: table-cell;
            padding: 16px 0;
  
            .cell-container {
              width: 100%;
              display: flex;
              justify-content: center;
              align-items: center;
            }
          }
        }
      }
  
      .body {
        color: var(--neutrals-70);
        display: table-row-group;
        height: 10px;
  
        .row {
          display: table-row;
          vertical-align: center;
  
          .cell {
            display: table-cell;
            border-spacing: 0;
            padding: 4px 0;
            vertical-align: middle;
  
            .cell-container {
              width: 100%;
              height: 100%;
              display: flex;
              align-items: center;
            }
          }
        }
  
      }
  
    }
  
 }

字符串

相关问题