2014-05-09 75 views
-1

正在深入挖掘并尽我所能理解,我应用了在发现类似问题时发现的解决方案,但忽略悬停。我错过了什么?风格适用于表格但忽略td:悬停忽略

<style type="text/css"> 
     .testTable td { 
      color: white; 
      width: 200px; 
      background-color: #44749D; 
      padding: 4px; 
      text-align: center;    
     } 
     .testTable td:hover { 
      color: 44749D !important; 
      background-color: C6D4E1 !important; 
     }    
    </style> 

<head> 
    <title>Table Test</title> 
</head> 
<body> 
    <table class="testTable"> 
     <tr> 
      <td>Row 1</td> 
     </tr> 
     <tr> 
      <td>Row 2</td> 
     </tr> 
     <tr> 
      <td>Row 3</td> 
     </tr> 
    </table> 
</body> 
</html> 

尝试过有和没有“!important”,有和没有使用过类名。 IE,td {...}和.testTable td {...}

回答

1

试试这个CSS。您是丢失的颜色(十六进制颜色值)的开头(#)

<style type="text/css"> 
     .testTable td { 
      color: white; 
      width: 200px; 
      background-color: #44749D; 
      padding: 4px; 
      text-align: center;    
     } 
     .testTable td:hover { 
      color: #44749D !important; 
      background-color: #C6D4E1 !important; 
     }    
    </style> 
0

你忘了#颜色& background-color;

  .testTable td:hover { 
       color: #44749D !important; 
       background-color: #C6D4E1 !important; 
      } 

你甚至可以删除!现在重要,因为它现在没有多大意义。

   .testTable td:hover { 
        color: #44749D; 
        background-color: #C6D4E1; 
       } 

替换代码和宾果游戏,将工作:)

+0

谢谢!我现在会回到我的角落。 。 。 – user2972124

+0

欢迎您:)如果它解决了您的问题,请将其标记为答案 – mohamedrias

1

失踪颜色之前。像背景颜色:#44749D;

<style type="text/css"> 
     .testTable td { 
      color: white; 
      width: 200px; 
      background-color: #44749D; 
      padding: 4px; 
      text-align: center;    
     } 
     .testTable td:hover { 
      color: #44749D !important; 
      background-color: #C6D4E1 !important; 
     }    
    </style> 

<head> 
    <title>Table Test</title> 
</head> 
<body> 
    <table class="testTable"> 
     <tr> 
      <td>Row 1</td> 
     </tr> 
     <tr> 
      <td>Row 2</td> 
     </tr> 
     <tr> 
      <td>Row 3</td> 
     </tr> 
    </table> 
</body> 
</html