问题描述
有没有办法使用 CSS 将 HTML 表格单元格内联在普通文本流中,使文本出现在周围文本的基线处?
简单地使所有表格元素内联会使文本向下移动,如下例所示,这是不可取的。
table,table > tbody,table > tbody > tr,table > tbody > tr > td {
display: inline;
}
table > tbody > tr > td {
padding: 0px;
margin: 0px;
}
<div style="width: 40em;">
A table containing
<table>
<tbody>
<tr>
<td>possibly multiple cells</td>
</tr>
<tr>
<td>containing potentially a high amount of text that should not be shifted down</td>
</tr>
<tbody>
</table>
below the baseline.
</div>
解决方法
要实现您的目标,您应该将 func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Dequeueing custom cell
let cell = self.tableView.dequeueReusableCell(withIdentifier: "CustomCell",for: indexPath as IndexPath) as! CustomCell
// Flag to display separators
if indexPath.row == 0 {
cell.showTopSeparator()
else if indexPath.row == data.count - 1 {
cell.showBottomSeparator()
}
return cell
}
添加到每个有问题的表格元素中。
此外,您不需要针对具有祖先层次结构的每个元素。这应该足够了:
import { types } from "pg";
types.setTypeParser(16,(value) => { // 16 is the type enum vaue of boolean
return Boolean(parseInt(value));
});
vertical-align: baseline;