2013-10-29 141 views
0

我有以下HTML:为什么不工作我的CSS类

<div id="main"> 
    <div id="calendar"> 
    <div class="column" id="time_slots"> 
    </div> 

     <div class="column" id="day1"> 
      <div class="route_container"> 
       <div class="date"></div> 
       <button class="add_route" name="add_route" onclick="">Add New Route - 1</button> 
       <div class = "truck" id="day1_route1"> 
        <div class="8-10">8-10 AM today</div>//want css for this 
        <div class="10-12">10-12 AM</div> 
        <div class="12-2">12-2 AM</div> 
        <div class="2-4">2-4 AM</div> 
        <div class="4-6">4-6 AM</div> 
       </div> 
      </div> 
     </div> 
      ...etc... 

然后我有以下CSS:

.label 
{ 
    width:20px; 
} 

.table 
{ 
    font-size: 1.2em; 
} 
#main 
{ 
    border-style: solid; 
    border-width: 1px; 
    border-color: black; 
    width:97%; 
    height:900px; 
    margin:auto; 
    overflow: auto; 
    white-space: nowrap; 

} 
h2 
{ 
    font-size: 24px; 
} 
#calendar 
{ 
    padding:1%; 

} 
.column 
{ 
    border-style: solid; 
    border-width: 1px; 
    border-color: black; 
    min-width:10%; 
    max-width:100%; 
    height:800px; 
    display: inline-block; 
    overflow: auto; 
    padding:5px; 
    font-size: 0px; 


} 
.header 
{ 
    padding:0; 
    margin:0; 
    text-align: center; 
    font-style: bold; 
} 

.truck 
{ 
    width:200px; 
    border-style: solid; 
    border-width: 1px; 
    border-color: black; 
    display:inline-block; 
    margin:auto; 
    font-size: 16px; 


} 

.column#time_slots 
{ 
    width:5%; 
    min-width:5%; 
    max-width: 10%; 
} 
.date 
{ 
    text-align: center; 
    width:100%; 
} 
.column button 
{ 
    display:block; 
    width:100%; 
    width:100%; 
    border-style: solid; 
    border-width: 1px; 
    border-color: black; 
    font-size: 16px; 
} 
.full_time 
{ 
    display: none; 
} 
.8-10 
{ 
    border-style: solid; 
    border-width: 1px; 
    border-color: black; 
    width:100px; 
    height:18px; 

    font-size: 24px;  
} 

的问题是,我试图定义的所有类对于8-10,10-12,12-2,2-4,& 4-6。我原本试过:

.8-10, .10-12, .12-2, .2-4, .4-6 
    { 
     border-style: solid; 
     border-width: 1px; 
     border-color: black; 
     width:100px; 
     height:18px; 

     font-size: 24px;  
    } 

但是没有奏效。我究竟做错了什么?我什至不能让一个班级(8-10)工作?我该如何解决?

+0

你,包括你的CSS文件,是否正确? – patricksweeney

+1

CSS类名不能以数字开头。更多信息http://stackoverflow.com/questions/448981/what-c​​haracters-are-valid-in-css-class-selectors – RafH

+0

谢谢你们。我不敢相信我做到了。 Smh ... – BlackHatSamurai

回答

3

它不起作用的原因是因为你不能在类名的开头使用数字。

Wrong: .123text 
Right: .text123 
+0

仅供参考......我会尽快接受:) – BlackHatSamurai

2

类名可以以下划线,短划线或字母开头,而不是数字开头。

“在CSS中,标识符(包括元素名,类和在 选择器ID)的只能包含字符[A-ZA-Z0-9]和ISO 10646 字符U + 00A0和更高的,加连字符( - )和下划线 (_);它们不能以数字,两个连字符或连字符 之后的数字开头。“

http://www.w3.org/TR/CSS21/syndata.html#characters