首页 > 解决方案 > HTML表格字问题

问题描述

自从我使用 HTML 和 CSS 以来已经有一段时间了,但我需要一些帮助。你看,当我尝试在 HTML 中制作表格并在 CSS 中设置样式时,结果如下:

http://prntscr.com/mw164x

        #row1 {
            border: 2px;
            border-spacing: 60%;
            border-collapse: none;
            border-color: solid black;
            border-style: solid;
            padding: 23px;
            width: 25px;
            height: 1px;
            background-color: url();
        }
<body>


    <table>

        <tr>
            <div id="row1">
                <td>My Account</td>
                <td>Payments/Transfers<td>
        </tr>

    </table>
    </div>



</body>

</html>

标签: javascripthtmlcss

解决方案


如果您只想要第一行的边框:

table {
  /* This makes borders visible, and removes spaces between cells */
  border-collapse: collapse; 
}

thead tr {
  /* This shows a border around the table head */
  border: 1px solid #000;
}
<table>
  <thead>
    <tr>
      <th>My Account</th>
      <th>Payments / Transfers</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>356</td>
      <td>$35</td>
    </tr>
    <tr>
      <td>432</td>
      <td>$23</td>
    </tr>
  </tbody>
</table>


推荐阅读