我有一张表,完成列只是复选框。
在<th>
我有一个提示“include?”现在想为<th>
中的复选框添加一些JS,可能还有一些“全/无”文本。
坏ascii艺术如下:
------------ ------------
| include? | | include? |
| [] | | [] all |
------------ ------------
| [] | or, maybe | [] |
------------ ------------
| [] | | [] |
------------ ------------
在任何一种情况下,我应该使用style
来核对该复选框?
答案 0 :(得分:3)
最简单的是使用text-align:center;
http://jsfiddle.net/jasongennaro/rhUjP/1/
修改强>
刚刚看到了你的其他要求,即我需要将文本左对齐,但要将中心复选框
在这种情况下,请将input
放入span
span{display:inline-block; text-align:center; width:100px;}
让width
与width
的{{1}}匹配。
答案 1 :(得分:2)
.checkbox {
display: block;
margin: auto;
}
或者您可以设置:
th {
text-align: center;
}
如果您希望整个class
居中,请指定要包含的id
或<th>
<th>
,例如:http://jsfiddle.net/minitech/pJxgc/。
答案 2 :(得分:2)
试试这个jsFiddle
<table>
<tbody>
<tr><th><input type="checkbox" class="checkbox" /> Hello</th></tr>
<tr><td>My Table Data!</td></tr>
</tbody>
</table>
th { text-align:center; }
答案 3 :(得分:0)
你的意思是this fiddle吗?