(I thought I might find an answer in Set the table column width constant regardless of the amount of text in its cells?, but none of the solutions there seem to work for me.)
I would like to build a table with two columns, one 30% of the text area width and the other filling the remaining space. Between cells I need about 1em of space so I can apply distinct borders around each cell. This is the current code:
table.condform {
margin-left: 50px;
margin-top: 1em;
table-layout: fixed;
width: 80%;
font-family: Courier, monospace;
font-size: xx-small:
padding: 0;
border-collapse: separate;
border-spacing: 2em;
border: none;
}
table.condform td {
padding: 0.1em 0.2em 0.3em 0.2em;
min-height: 1em;
vertical-align: top;
}
table.condform td:first-of-type {
width: 40%;
}
table.condform td:nth-of-type(2) {
width: auto;
<table class="condform">
<colgroup>
<col style="width: 40%;">
<col style="width: auto;">
</colgroup>
<tr>
<td style="border: red 1px solid; background-color: #ff0">a</td>
<td>b</td>
</tr>
<tr>
<td style="border: blue 1px solid; background-color: #0ff">a</td>
<td>b</td>
</tr>
</table>
Regardless of what I do the cells shrink down to fit their contents, and nothing I do seems to affect cell spacing:
I've tried six or seven different fixes now, including all the ones in the link above, but to no avail. Surely setting column widths and cell spacing can't be beyond the abilities of CSS?
EDIT 20161221 1040: Setting td
width values in pixels works, but I'm not keen on specifying pixel values if I can help it.
EDIT 20161221 1052: Looking in the element inspector it seems that the table class isn't applying properly. It's a table
, its class is condform
, but none of that class's styles are showing up in the style field. (I know there are blank properties, but they shouldn't be causing any trouble and haven't elsewhere.) Subordinate styles are still applying properly, as evidenced by the fact that pixel widths work.
I'm flummoxed now.