TD标签中的值不相应地在表头(React-Bootstrap)上方

发布于 2025-02-12 15:23:00 字数 1358 浏览 3 评论 0原文

我正在尝试使用Bootstrap在ReactJ中创建一个表。除了:

如您所见,Thead标签内的标题并不完全对齐其相应的TD标签。有办法做到吗?

这是代码:

<Table striped hover responsive >
  <thead>
    <tr>
      <th>Rank</th>
      <th>Logo</th>
      <th>Name</th>
      <th ></th>
      <th>Wins</th>
      <th>Loss</th>
      <th>Draws</th>
      <th>Games</th>
      <th>GF</th>
      <th>GA</th>
    </tr>
  </thead>
  <tbody>
    {team && team.map((team, key) =>{
      return <tr key={key}>
        <td>{key + 1}</td>
        <td><img src={team.team.logos[0].href} alt='team logo' width={40} height={40}/></td>
        <td >{team.team.name}</td>
        <td>{team.stats[0].value}</td>
        <td>{team.stats[1].value}</td>
        <td>{team.stats[2].value}</td>
        <td>{team.stats[3].value}</td>
        <td>{team.stats[4].value}</td>
        <td>{team.stats[5].value}</td>
      </tr>
    })}
  </tbody>
</Table>

I am trying to create a table in reactjs using bootstrap. Everything seems fine except:
enter image description here

As you can see, the titles inside the thead tag is not aligned exactly above its corresponding td tag. Is there a way to do it?

Here is the code:

<Table striped hover responsive >
  <thead>
    <tr>
      <th>Rank</th>
      <th>Logo</th>
      <th>Name</th>
      <th ></th>
      <th>Wins</th>
      <th>Loss</th>
      <th>Draws</th>
      <th>Games</th>
      <th>GF</th>
      <th>GA</th>
    </tr>
  </thead>
  <tbody>
    {team && team.map((team, key) =>{
      return <tr key={key}>
        <td>{key + 1}</td>
        <td><img src={team.team.logos[0].href} alt='team logo' width={40} height={40}/></td>
        <td >{team.team.name}</td>
        <td>{team.stats[0].value}</td>
        <td>{team.stats[1].value}</td>
        <td>{team.stats[2].value}</td>
        <td>{team.stats[3].value}</td>
        <td>{team.stats[4].value}</td>
        <td>{team.stats[5].value}</td>
      </tr>
    })}
  </tbody>
</Table>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷默言语 2025-02-19 15:23:00

我看不到代码,但是TD似乎有一定的余量。但是,由于TD中列出的数据中的单词数量,您仍然会遇到它的问题。一个解决方案将单独使用每个TD进行样式,直到您获得想要的方式为止。

I cannot see the code, but there seems to be some margin for the td. But you will still have issues with it lining up due to the number of words in td to the data listed. A solution would be styling each td by itself until you get it how you'd like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文