rowspan不工作html

时间:2014-12-14 06:14:42

标签: html css

我有一张桌子,我正在尝试完成这样的事情,enter image description here

到目前为止,我已经关注了html,我想我可以使用rowspan但是尝试了它并没有给我预期的结果

<table class="table tab-content" style="width:95%" align="center">
    <tr class="row">
        <td colspan="2">
            <h4 class="h4">This is a new Car please call</h4>
        </td>
    </tr>
    <tr class="row">
        <td style="width:100px; height=100%;" rowspan="2">
            <img width="100%" src="adimg/autos/11.jpg" />
        </td>
        <td style="width:70%">this is a car ad this is a car adthis is a car adthis is a car adthis is a car ad this is a car adthis is a car adthis is a car adthis is a car adthis is a car ad this is a car ad this is a car adthis is a car adthis is a car adthis is a car ad this is a car adthis is a car adthis is a car ... &nbsp&nbsp <a style="font-weight:bold; color:Red" href="#">3 mins ago</a>
        </td>
        <td valign="top">$5000</td>
        <td><b>Smart Cars</b>
        </td>
    </tr>
</table>

3 个答案:

答案 0 :(得分:2)

您必须将rowspan <td>作为第一个<tr>中的第一个元素。

跨度向下工作,所以你现在所拥有的是第二行跨越第三行。

Working fiddle

答案 1 :(得分:0)

将带有图像放在顶行,它应该可以正常工作。

<table class="table tab-content" style="width:95%" align="center">
<tr class="row">
        <td style="width:100px; height=100%;" rowspan="2">
        <img width="100%" src="adimg/autos/11.jpg" />
    </td>
    <td colspan="2">
        <h4 class="h4">This is a new Car please call</h4>
    </td>

</tr>
<tr class="row">

    <td style="width:70%">this is a car ad this is a car adthis is a car adthis is a car adthis is a car ad this is a car adthis is a car adthis is a car adthis is a car adthis is a car ad this is a car ad this is a car adthis is a car adthis is a car adthis is a car ad this is a car adthis is a car adthis is a car ... &nbsp&nbsp <a style="font-weight:bold; color:Red" href="#">3 mins ago</a>
    </td>
    <td valign="top">$5000</td>
    <td><b>Smart Cars</b>
    </td>
</tr>

答案 2 :(得分:0)

图像应该在rowspan = 2的顶行,这将把它放在2行。此外,包含的td应该具有colspan = 3以覆盖行的其余部分。 Colspan = 2这里将在“智能汽车”单元格上方的这一行留下空隙 第二行自动适合第一列中的图像,因为之前给出的行数和行的其余3列如下。

<table class="table tab-content" style="width:95%" align="center">
<tr class="row">
        <td style="width:100px; height=100%;" rowspan="2">
        <img width="100%" src="adimg/autos/11.jpg" />
    </td>
    <td colspan="3">
        <h4 class="h4">This is a new Car please call</h4>
    </td>

</tr>
<tr class="row">

    <td style="width:70%">this is a car ad this is a car adthis is a car adthis is a car adthis is a car ad this is a car adthis is a car adthis is a car adthis is a car adthis is a car ad this is a car ad this is a car adthis is a car adthis is a car adthis is a car ad this is a car adthis is a car adthis is a car ... &nbsp&nbsp <a style="font-weight:bold; color:Red" href="#">3 mins ago</a>
    </td>
    <td valign="top">$5000</td>
    <td><b>Smart Cars</b>
    </td>
</tr>