I am creating a crossword generator and aim to use HTML and CSS, along with Jinja2 templates to represent the crossword.
I have chosen to use the table
element to represent the crossword (the crossword is always square):
<table class="table">
{% for row in range(dimensions) %}
<tr>
{% for column in range(dimensions) %}
<td>{{ . }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
I have had trouble making this table fill the screen appropriately; I am trying to make it expand outwards equally until it cannot expand any further, with a little bit of padding on either sides.
Could anyone help me write some CSS to ensure the table expands outwards dynamically, retaining a square shape, keeping a bit of padding on both sides and keeping all <td>
elements an equal size?
4
Answers
I hope I understood you correctly and you need the aspect-ratio property along with table-layout: fixed;
Something like that ?
You can try the css like this,
--td-siz
variable),border-collapse
,border-spacing
, and background color.td:not(:empty)
block styles non-empty cells within the table. It sets thebackground-color
,width
,height
,text-align
, andtext-transform
properties. The:not(:empty)
selector ensures that only non-empty cells are styled.<table>
element, with each letter placed in a separate cell. Empty cells are represented with<td></td>
.