The cell contains nothing but a checkbox. It is rather wide because of text in the table header row. How do I center the checkbox (with inline CSS in my HTML? (I know))
If you don't support legacy browsers, I'd use flexbox because it's well supported and will simply solve most of your layout problems.
#table-id td:nth-child(1) {
/* nth-child(1) is the first column, change to fit your needs */
display: flex;
justify-content: center;
}
This centers all content in the first <td>
of every row.
Define the float property of the check element to none:
float: none;
And center the parent element:
text-align: center;
It was the only that works for me.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-bordered">
<thead>
<tr>
<th></th>
<th class="text-center">Left</th>
<th class="text-center">Center</th>
<th class="text-center">Right</th>
</tr>
</thead>
<tbody>
<tr>
<th>
<span>Bootstrap (class="text-left")</span>
</th>
<td class="text-left">
<input type="checkbox" />
</td>
<td class="text-center">
<input type="checkbox" checked />
</td>
<td class="text-right">
<input type="checkbox" />
</td>
</tr>
<tr>
<th>
<span>HTML attribute (align="left")</span>
</th>
<td align="left">
<input type="checkbox" />
</td>
<td align="center">
<input type="checkbox" checked />
</td>
<td align="right">
<input type="checkbox" />
</td>
</tr>
</tbody>
</table>
This should work, I am using it:
<td align="center"> <input type="checkbox" name="myTextEditBox" value="checked" ></td>