为什么rowspan html不能按预期工作?

时间:2018-12-23 16:29:23

标签: html html-table

我正尝试创建一个表格布局,如下图所示:

https://imgur.com/c4M6gAM

<table>
    <tr>
        <td rowspan="3">1</td>
        <td>2</td>
        <td rowspan="2">3</td>
    </tr>
    <tr>
        <td rowspan="2">4</td>
    </tr>
    <tr>
        <td>5</td>
    </tr>
</table>

实际结果:

enter image description here

1 个答案:

答案 0 :(得分:2)

It works if we use height and width for td and tr

<html>
<head>
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
border-collapse:collapse;
}
tr{
height:50px;
}
td{
width:30px;
}
</style>
</head>
<body>
   <table>
    <tr>
        <td rowspan="3"></td>
        <td></td>
        <td rowspan="2"></td>
    </tr>
    <tr>
        <td rowspan="2"></td>
    </tr>
    <tr>
        <td></td>
    </tr>
</table>
  </body>

</html>

</body>
</html>