我有一张桌子.我只想让第一列左对齐,其他列对齐.我使用以下样式:
<style>
table{ width:100%;}
.1col{ text-align:left;}
.othercols{width:100px;}
table>tbody>tr>td, table>tbody>tr>th { text-align:center;}
</style>
Run Code Online (Sandbox Code Playgroud)
然后我有我的桌子:
<table>
<tr>
<th class="1col">Category</th>
<th class="othercols">Some text</th>
<th class="othercols">Some text</th>
<th class="othercols">Some text</th>
</tr>
<tr >
<td class="1col">Some text</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
结果是我的1col类被忽略了.任何的想法?
CSS类不能以整数开头,所以请尝试col1改为.
工作示例:http://jsfiddle.net/9X7kz/8/
如果您有兴趣,这是完整的语法:
http://www.w3.org/TR/CSS21/grammar.html#scanner
这是具体的规则规范:
http://www.w3.org/TR/CSS21/syndata.html#characters
在CSS中,标识符(包括选择器中的元素名称,类和ID)只能包含字符[a-zA-Z0-9]和ISO 10646字符U + 00A0和更高,加上连字符( - )和下划线( _); 它们不能以数字,两个连字符或连字符后跟数字开头.标识符还可以包含转义字符和任何ISO 10646字符作为数字代码(请参阅下一项).例如,标识符"B&W?" 可以写成"B \&W \?" 或"B\26 W\3F".