Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I emulate a table with divs & css?

Tags:

css

html-table

A table like this one:

<table>

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

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

  ...
</table>

How can I create one using div and css display:table rules ?

like image 557
thelolcat Avatar asked Dec 28 '12 14:12

thelolcat


1 Answers

Try this ;)

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>
like image 194
rjanjic Avatar answered Sep 18 '22 12:09

rjanjic