8

像这样的表:

<table>

  <tr>
   <td> ... </td>
   <td> ... </td>
   <td> ... </td>
  </tr>

  <tr>
   <td> ... </td>
   <td> ... </td>
   <td> ... </td>
  </tr>

  ...
</table>

如何使用 div 和 css display:table 规则创建一个?

4

1 回答 1

30

试试这个 ;)

CSS

.table {
    display: table;
    width: 500px;
}
.tr { 
    display: table-row; 
}
.td { 
    display: table-cell;
}

HTML

<div class="table">
    <div class="tr">
        <div class="td">asdf</div>
        <div class="td">asdf</div>
        <div class="td">asdf</div>
    </div>
    <div class="tr">
        <div class="td">asdf</div>
        <div class="td">asdf</div>
        <div class="td">asdf</div>
    </div>
</div>
于 2012-12-28T14:18:19.360 回答