To achieve a table with square cells, I implemented the following CSS:
table {
width: 100%;
table-layout: fixed;
}
td {
text-align: center;
vertical-align: middle;
}
td:before {
content: '';
padding-top: 100%;
float: left;
}
However, the vertical-align property does not work as expected for cell content. Can anyone suggest a solution?
The HTML code used is as follows:
<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>