html - 隐藏动态生成的 border-top 属性 <td>

标签 html css reactjs twitter-bootstrap

我有一个模态 react 组件,它呈现一个表格,该表格遍历用户/电子邮件数组 (waitList) 并将它们显示在标签中。我的目标是只删除行中的第一个 border-top 属性(见图)。

an image of my table and which border i want removed

这是我的组件的一个片段,以防我的描述不清楚-

  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>

关于html - 隐藏动态生成的 border-top 属性 <td>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55292153/

相关文章:

html - 如何在 TBODY 元素之间放置间距

html - Safari 上带有 margin-right negative 的布局差异

html - CSS - WebBrowser 页面宽度响应和精确 : Best Practises

jquery - 制作一个文本字段和一个全宽的按钮

javascript - 需要建议 : How to properly connect React to MongoDB

reactjs - 使用babel从node_modules导入模块但失败

javascript - 将 div 放在 Master Slider 的顶部

javascript - HTML5 可排序和 Ember.JS

html - 不同浏览器 HTML 对齐

javascript - 如何在 KeyDown 事件中调用子组件中父组件中定义的函数?