html - 如何消除表标签生成的默认空间?

标签 html css html-table

html,body{
  width:100%;
  height:100%;}
tr{
  width:100%;
  height: 10%;
  float: left;
}
.col{
  width: 10%;
  height: 100%;
  float: left;
}
.odd{
  background-color: green;
}
.even{
  background-color: #fff;
}
#rw-one,#rw-three,#rw-five,#rw-seven,#rw-nine{
  /*width: 100%;
  height: 100%;*/
  z-index: 999;
  background-color: red;
}
table{
  width:100%;
  height: 100%;
  background-color: orange;
  border:none;
}
<table>
  <tr id="rw-one">
    <td class="odd col"> </td>
    <td class="even col"> </td>
    <td class="odd col"> </td>
    <td class="even col"> </td>
    <td class="odd col"> </td>
    <td class="even col"> </td>
    <td class="odd col"> </td>
    <td class="even col"> </td>
    <td class="odd col"> </td>
    <td class="even col"> </td>
  </tr>
  <tr id="rw-two"></tr>
  <tr id="rw-three"></tr>
  <tr id="rw-four"></tr>
  <tr id="rw-five"></tr>
  <tr id="rw-six"></tr>
  <tr id="rw-seven"></tr>
  <tr id="rw-eight"></tr>
  <tr id="rw-nine"></tr>
  <tr id="rw-ten"></tr>
</table>

在上面的代码中,我尝试创建一个有 10 行的表格,第一行有 10 列。表格有一个 width:100%; 并且每一行都有一个 height:10%;height:100%;。每一行又被分成 10 个部分(每个宽度:10%)。但是 10 列没有第一行放不下。可能会通过 or 标记生成一些默认空间,我该如何解决这个问题?

最佳答案

尝试将 padding:0 添加到您的 .col 类中。

.col{
 padding:0;
 width: 10%;
 height: 100%;
 float: left;
}

我认为这应该可行。看这个codepen

关于html - 如何消除表标签生成的默认空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40790843/

相关文章:

php - 多个 HTML 页面和分页

css渐变给滚动条

javascript - 如何使用 JavaScript 缩放图像以适应

html - 表格边框 html

javascript - 在 JavaScript 中将值从一个页面传递到另一个页面

python - 获取 <br/> 之前的文本 python/bs4

javascript - 从 2D JavaScript 数组生成 HTML 表格

javascript - 附加的新行的行为与前一行(行)不同

javascript - 浏览 https protected 网站时出现问题

html - 使用固定大小的正文打印时如何删除 HTML 右边距?