该单元格仅包含一个复选框。由于表标题行中的文本,所以它很宽。如何将复选框居中(在HTML中包含内联CSS?(我知道))
我试过了
<td>
<input type="checkbox" name="myTextEditBox" value="checked"
style="margin-left:auto; margin-right:auto;">
</td>
但这没用。我究竟做错了什么?
更新:这是一个测试页。有人可以更正它吗(在HTML中使用CSS内联),以使复选框位于其列的中心?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Alignment test</title>
</head>
<body>
<table style="empty-cells:hide; margin-left:auto; margin-right:auto;" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Search?</th><th>Field</th><th colspan="2">Search criteria</th><th>Include in report?<br></th>
</tr>
<tr>
<td>
<input type="checkbox" name="query_myTextEditBox" style="text-align:center; vertical-align: middle;">
</td>
<td>
myTextEditBox
</td>
<td>
<select size ="1" name="myTextEditBox_compare_operator">
<option value="=">equals</option>
<option value="<>">does not equal</option>
</select>
</td>
<td>
<input type="text" name="myTextEditBox_compare_value">
</td>
<td>
<input type="checkbox" name="report_myTextEditBox" value="checked" style="text-align:center; vertical-align: middle;">
</td>
</tr>
</table>
</body>
</html>
我已经接受@Hristo的回答-这就是内联格式...
<table style="empty-cells:hide;" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Search?</th><th>Field</th><th colspan="2">Search criteria</th><th>Include in report?<br></th>
</tr>
<tr>
<td style="text-align: center; vertical-align: middle;">
<input type="checkbox" name="query_myTextEditBox">
</td>
<td>
myTextEditBox
</td>
<td>
<select size ="1" name="myTextEditBox_compare_operator">
<option value="=">equals</option>
<option value="<>">does not equal</option>
</select>
</td>
<td>
<input type="text" name="myTextEditBox_compare_value">
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="checkbox" name="report_myTextEditBox" value="checked">
</td>
</tr>
</table>
<td align =“ center”> <input type =“ checkbox” name =“ myTextEditBox” value =“ checked”> </ td>将使其在IE8,9中工作。但是,在IE10或chrome中,无论您是否看到该复选框,复选框或单选框都是在框中定义的。该框将始终保持对齐状态。但是在定义框内,复选框或单选框居中。如果包含的TD的宽度为100px,则复选框为50px,则它始终保持对齐。要使复选框居中,可以将复选框的定义框设置为100px,这与包含的TD的宽度相同。
—
qeq