2014-05-09 73 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