How to ensure that each cell of table should become square without using fixed sizes? And be responsive when they change width.
table {
width: 90%;
}
td {
width: 30%;
}
tr {
/** what should go here? **/
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<table>
You can use the technique described in: Grid of responsive squares.
Adapted to your usecase with a table and square table cells, it would look like this:
FIDDLE demo
Here is my code: http://jsfiddle.net/vRLBY/1/
The key is to use:
because
padding-bottom
is defined in terms of the width. More information: http://absolide.tumblr.com/post/7317210512/full-css-fluid-squaresNote: Previously I posted a not working code (see here). Thanks to @web-tiki for reporting the bug ;-)