html - 隐藏动态生成的border-top属性
问题描述
我有一个模态反应组件,它呈现一个遍历用户/电子邮件数组(waitList)并将它们显示在标签中的表。我的目标是只删除行中的第一个border-top 属性(见图)。
这是我的组件的一个片段,以防我的描述不清楚 -
renderTableRows() {
const iter = [];
if (this.props.waitList !== null) {
this.props.waitList.map(applicant => {
iter.push(
<tr>
<td>{applicant.user.name}</td>
<td>{applicant.user.email}</td>
</tr>
);
});
}
return iter;
}
render() {
return (
<div>
<Modal show={this.state.waitListModalIsOpen}>
<Modal.Header>
WAIT LIST ({this.props.waitListCount})
</ Modal.Header>
<Modal.Body>
<table className={'table wait-list-table'}>
<tbody>
{this.renderTableRows()}
</tbody>
</table>
</ Modal.Body>
<Modal.Footer>
<Button onClick={() => { this.closeWaitListModal(); }}>Cancel</Button>
</ Modal.Footer>
</Modal>
</div>
);
}
}
我明白,因为我在td
这里迭代每个 nth-child 将删除提供的子参数的所有边框,而不仅仅是列表中的第一个。有没有办法可以使用 CSS 隐藏这个边框?如果没有,欢迎提出如何改进我的 React 组件中的迭代逻辑的建议。
解决方案
table tr td {border-top: solid gray 1px; }
table tr:first-child td {border-top: none;}
<table>
<tbody>
<tr>
<td>a</td>
<td>b</td>
</tr>
<tr>
<td>aa</td>
<td>bb</td>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
</tr>
</tbody>
</table>
推荐阅读
- python - paramiko invok shell 只收到结果
- python - BERT 转换器 KeyError:3
- arrays - 如何创建一个数组,其中每个元素都与其他 2 个值相关联?
- javascript - 未捕获的类型错误:paymentForm.requestCardNonce 不是函数 未生成令牌
- python - Jira Python session() 接受 1 个位置参数,但给出了 2 个
- node.js - Textarea多值输入,类似trackingid网站
- python - 根据标签值垂直重新排列桑基图
- reactjs - 如何在反应js中映射以下api响应
- python - 有没有办法使用python脚本在文本文件中用“~\n”替换“~”符号
- java - 有没有办法根据用户输入定义要创建的对象?