CSS Tables Colspan

时间:2013-09-13 20:49:16

标签: html css html-table

好吧,我现在尝试不使用HTML表。但我正在使用CSS表,但我想知道CSS表中是否有相同的colspan。

我有这段代码

#fleetTable{display: table;width: 360px;margin: 0 auto;margin-top: 20px;font-size:.875em;float:left;}
    .fleetRow{display: table-row;}
    .fleetCell{display: table-cell;}

这个HTML

<div id="fleetTable">
    <div class="fleetRow textright">
        <div class="fleetCell">Headline</div> <!-- I would like this to span both columns below but be centered -->
    </div>
    <div class="fleetRow textright">
        <div class="fleetCel;">Cell1</div>
        <div class="fleetCell">Cell2</div>
    </div>
</div>  

你会在这里使用什么选择器来实现这个目标?

1 个答案:

答案 0 :(得分:1)

我明确假设您的标题将是第一行的第一个单元格,并且具有.fleetCell类。因此,您可以使用:first-child伪选择器选择此第一个元素。

CSS

.fleetCell:first-child{
   text-align:center;
}

JS Fiddle Example