下面是我的代码片段,我试图实现的是在给定宽度上扩展宽度基数(600px,因为你可以看到有一个宽度为600px的div)而没有调整其容器的大小(td,你可以看到td正在扩展,也是基于它的子宽度为600px,我不想要)。我希望宽度为600px的div与在aug和sep下的td容器对齐,有没有办法实现呢?
#table_roadmap th, #table_roadmap td {
padding: 8px;
border: 1px solid rgba(0, 0, 0, 0.1);
}
#table_roadmap thead {
background-color: #ededed;
}
#table_roadmap th:first-child {
background-color: #40b649;
color: #ffffff;
}
#table_roadmap th {
text-align: center;
font-weight: 700;
}
#table_roadmap tbody tr td:first-child {
background-color: #40b649 !important;
color: #ffffff !important;
font-weight: 700 !important;
width: 200px !important;
}
#table_roadmap tbody td {
height: 100px;
width: 300px;
}
#table_roadmap .roadmap_card_main {
padding: 3px 5px;
font-size: 10px;
margin: 3px;
background-color: green;
color: #fff;
}

<table id="table_roadmap" class="center" cellpadding="0" cellspacing="0">
<thead>
<th>Projects</th>
<th>Jan</th>
<th>Feb</th>
<th>Mar</th>
<th>Apr</th>
<th>May</th>
<th>Jun</th>
<th>Jul</th>
<th>Aug</th>
<th>Sep</th>
<th>Oct</th>
<th>Nov</th>
<th>Dec</th>
</thead>
<tbody>
<tr>
<td>Project 1
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>
<div class="roadmap_card_main extend clear bg_green">Card title test 1</div>
<div class="roadmap_card_main extend clear bg_green" style="position: relative; width: 600px;">Card title test 1</div>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>Project 2</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>
<div class="roadmap_card_main extend clear bg_green">Card title test 1</div>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>Project 3
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>
<div class="roadmap_card_main extend clear bg_green">Card title test 1</div>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>Bug Checking</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>
<div class="roadmap_card_main extend clear bg_green">Card title test 1</div>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
</tbody>
</table>
&#13;