I am trying to create a <table>
element with nested rows and different colspans. Here is a little wireframe to show what I mean. How do I approach this?
Asked
Active
Viewed 137 times
1
-
Does it need to be dynamic? If not, just hard-code it. – Geshode May 27 '21 at 15:26
-
1Step one. Try something, then come on back if you run into a problem. – Chris W. May 27 '21 at 15:27
-
I also fail to see how this would be for tabular data in the first place – tacoshy May 27 '21 at 16:02
1 Answers
0
Using nested tables does the job well:
#wrapper{
border-spacing: 0px;
border-radius: 10px;
overflow: hidden;
}
#wrapper th {
height: 30px;
background-color: #6D6D6D;
}
#wrapper td{
vertical-align: top;
padding:10px;
}
.darkblock{
background-color:#555555;
height:20px;
width:50px;
border-radius:25px;
}
.greyblock{
background-color:#BDBDBD;
height:20px;
width:50px;
border-radius:25px;
margin-top:10px;
}
.long-block{
width:150px;
background-color:white;
height:20px;
border-radius:25px;
}
#wrapper .row {
background-color: lightgrey;
}
.inner{
padding: 0 !important;
}
<table id="wrapper">
<tr>
<th></th>
<th></th>
<th></th>
</tr>
<tr class="row">
<td>
<div class="darkblock"></div>
</td>
<td>
<div class="darkblock"></div>
<div class="greyblock"></div></td>
<td class="inner">
<table>
<tr>
<td><div class="darkblock"></div></td>
<td><div class="darkblock"></div></td>
<td><div class="darkblock"></div></td>
</tr>
<tr>
<td colspan="3"><div class="long-block"></div></td>
</tr>
</table>
</td>
</tr>
<tr class="row">
<td>
<div class="darkblock"></div>
</td>
<td>
<div class="darkblock"></div>
<div class="greyblock"></div></td>
<td class="inner">
<table>
<tr>
<td><div class="darkblock"></div></td>
<td><div class="darkblock"></div></td>
<td><div class="darkblock"></div></td>
</tr>
<tr>
<td colspan="3"><div class="long-block"></div></td>
</tr>
</table>
</td>
</tr>
<tr class="row">
<td>
<div class="darkblock"></div>
</td>
<td>
<div class="darkblock"></div>
<div class="greyblock"></div></td>
<td class="inner">
<table>
<tr>
<td><div class="darkblock"></div></td>
<td><div class="darkblock"></div></td>
<td><div class="darkblock"></div></td>
</tr>
<tr>
<td colspan="3"><div class="long-block"></div></td>
</tr>
</table>
</td>
</tr>
</table>

Spectric
- 30,714
- 6
- 20
- 43