gpt4 book ai didi

html - 表 td 不是 100%

转载 作者:太空宇宙 更新时间:2023-11-03 22:41:05 25 4
gpt4 key购买 nike

我想知道为什么我的 td 在我的表中没有得到 100%。

此代码需要存在:

.table-scroll tbody {
display: block;
overflow-y: scroll;
height: calc(100% - 130px);
}

当我使用显示 block 时会发生这种情况,无论如何我尝试了很多东西并且 td 仍然没有获得 100% 的表格

jsfiddle:https://jsfiddle.net/zuxq2gr0/1/

CSS:

.panel-table {
height:auto;
width:300px;
border: 1px solid red;
}

.table-scroll tbody {
display:block;
overflow-y: scroll;
height: calc(100% - 130px);
}

html:

  <!doctype html>
<html>
<head>
<title>Aurelia</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="panel-table">
<table class="table table-scroll">
<thead>
</thead>
<tbody>
<tr>
<td>Joseph</td>
</tr>
<tr>
<td>Mary</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
<tr>
<td>Judy</td>
</tr>
</tbody>
</table>
</div>
</body>

</html>

最佳答案

你可以添加这个样式:

.table-scroll tbody > tr {
display: table;
width: 100%;
}

这是更新的 fiddle

为什么你的 tbody 需要是 display: block?你正在破坏表格布局,你会得到像这样的奇怪行为。

关于html - 表 td 不是 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43983483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com