[英]Horisontal HTML table with vertical data
I have been struggling to create a html table(I also use bootstrap). 我一直在努力创建一个html表(我也使用bootstrap)。 To make it easier to understand what I want to achieve, see picture below.
为了更容易理解我想要实现的目标,请参见下图。
https://s15.postimg.org/ulq2gxap7/Hiro_Table.jpg https://s15.postimg.org/ulq2gxap7/Hiro_Table.jpg
Depending on how many elements(lets say cars), the user selects, I want to create a column for each car. 根据用户选择的元素数量(我说是汽车),我想为每辆汽车创建一列。 I have an array with the id of the selected itmes.
我有一个数组,其中包含选定主题的ID。
For now I do like this: 现在我喜欢这样:
For(selected){
//get data from my object with id
.....
$('table thead tr').append(html);
$('table tbody').append(htmlData);
}
Which outputs: 哪个输出:
-----car1-------------car2--------------car3 ----- CAR1 ------------- CAR2 --------------的Car3
----1911-------------Italian------------Red ---- 1911年------------- ------------意大利红
----1923 ------------Italian------------Yellow ---- 1923 ------------意大利语------------黄色
----1923 -----------Swedish------------Green ---- 1923 -----------瑞典------------绿色
I want as the picture I link to. 我想要作为链接的图片。
You didn't supplied the full HTML and JS code but basically between each TR with three TDs you need to append tr with td that have collspan=3 您没有提供完整的HTML和JS代码,但基本上在每个TR与三个TD之间,您需要在tr后面加上collspan = 3的td
for example: 例如:
table td { border: 1px solid #CCC; text-align: center; }
<table> <tr> <td colspan="3">italian</td> </tr> <tr> <td>Fiat</td> <td>Ferarri</td> <td>1992</td> </tr> <tr> <td colspan="3">German</td> </tr> <tr> <td>BMW</td> <td>VW</td> <td>Mercedes</td> </tr> </table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.