设置html表的宽度td

时间:2012-07-23 18:25:48

标签: html css

我有以下代码:

<table>
 <thead>
    <th class='1'>Date</th>
    <th class='2'>Start Time</th>
    <th class='3'>End Time </th>
    <th class='4'>Location</th>
</thead>
  <tbody>
    <td class='1'>Date</td>
    <td class='2'>Start Time</td>
    <td class='3'>End Time </td>
    <td class='4'>Location</td>
</tbody>
</table>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

和css

 table {width:550px;}
​.1 {width:60px; background-color:green;}
.2 {width:90px; background-color:blue;}
.3 {width:90px; background-color:red;}
.4 {width:100px; background-color:yellow;}​

为什么我不能设置宽度?背景颜色也没有改变,因此我必须有代码错误。

1 个答案:

答案 0 :(得分:2)

班级名称不能以数字开头。尝试重命名您的类以开始一个字母(a-z)。

JS小提琴:http://jsfiddle.net/sDKp2/

相关问题