【发布时间】:2018-12-09 19:16:32
【问题描述】:
我正在破解 Bootstrap 表以实现可点击的行。我觉得我非常接近我的目标,但是我遇到了单元格填充问题。
考虑一下这个小提琴:https://jsfiddle.net/aq9Laaew/64614/
tr.table-href > td {
padding: 0;
}
a.table-href {
padding: 0.75rem;
display: block;
}
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container">
<div class="row">
<table class="table">
<thead>
<tr>
<th scope="col">Col 1</th>
<th scope="col">Col 2</th>
<th scope="col">Col 3</th>
<th scope="col">Col 4</th>
</tr>
</thead>
<tbody>
<tr class="table-href">
<td>
<a class="table-href" href="#">Much much longer val than usual</a>
</td>
<td>
<a class="table-href" href="#">Val 2</a>
</td>
<td>
<a class="table-href" href="#">Some value 3</a>
</td>
<td>
<a class="table-href" href="#">Some value 4</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
如您所见,我将td 填充设置为0,以便内部的a 可以填充内容,从而使整个单元格可点击。但是,当某些单元格太宽并被包裹时,较短的单元格无论如何都会插入一些底部填充,即使 Chrome 开发工具告诉我没有:
问题:如何去掉这个填充,让里面的a 完全填满单元格表?
【问题讨论】:
-
不是填充。您的问题是真的吗,如何将
a扩展至与其父级一样高? -
@MrLister 我不知道它是什么。它显示为填充,它充当填充,所以我使用我认为适用的任何命名。
标签: html css html-table bootstrap-4