2017-08-17 82 views
0

我試圖改變懸浮顏色的響應表,但失敗了一個簡單的技巧。更改懸浮顏色的響應表

我嘗試鏈接CSS但失敗。

是否需要添加更多CSS標籤才能實現此目的。

請你幫我理解我的方法有什麼問題。

這裏是我的代碼:

<!DOCTYPE html> 
<html> 
<head> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
    <script> 
.table-hover thead tr:hover th, .table-hover tbody tr:hover td { 
    background-color: #FF0000; 
} 
    </script> 
</head> 
<body> 

<div class="container"> 
    <h2>Table</h2> 
    <p>The .table-hover class enables a hover state on table rows within a tbody:</p> 

<table class="table table-hover"> 
    <thead> 
     <tr> 
      <th>Firstname</th> 
      <th>Lastname</th> 
      <th>Email</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td>John</td> 
      <td>Doe</td> 
      <td>[email protected]</td> 
     </tr> 
     <tr> 
      <td>Mary</td> 
      <td>Moe</td> 
      <td>[email protected]</td> 
     </tr> 
     <tr> 
      <td>July</td> 
      <td>Dooley</td> 
      <td>[email protected]</td> 
     </tr> 
    </tbody> 

    </table> 
</div> 

</body> 
</html> 
+0

它是爲我工作的罰款 – user8256287

+0

感謝傑森。你能確認你是否能看到懸停或灰色的紅色。其實我想要懸停的紅色,但我可以看到灰色的顏色 –

回答

0

你必須把風格,而不是腳本對CSS

這裏使其:

<style> 
.table-hover thead tr:hover th, .table-hover tbody tr:hover td { 
    background-color: #FF0000; 
} 
</style>