我有一张 table 。我只希望第一列左对齐,其他列右对齐。我使用以下样式:
<style>
table{ width:100%;}
.1col{ text-align:left;}
.othercols{width:100px;}
table>tbody>tr>td, table>tbody>tr>th { text-align:center;}
</style>
然后我有我的 table :
<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>
结果是我的 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
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B\&W\?" or "B\26 W\3F".
关于html - 为什么要覆盖 css 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11965173/