質問宜しくお願い致します。
テーブルのhoverで背景色を1行すべて変えたいのですが、
単純にできるはずなのですが、うまくいきません。
https://nodoame.net/archives/4086
.sp_table tr:hover をtd:hoverにすれば変わるのですが、
trで1行まるごど変えたいのですがtrは効きません。
根本的にテーブルの作りがどこかおかしいのか、ずっと睨めっこをしてもわかりません…。
html
1<table class="sp_table"> 2 <tbody> 3 <tr> 4 <th>左の内容</th> 5 <td>テキストテキストテキスト</td> 6 </tr> 7 <tr> 8 <th>左の内容</th> 9 <td>テキストテキストテキスト</td> 10 </tr> 11 <tr> 12 <th>左の内容</th> 13 <td>テキストテキストテキスト</td> 14 </tr> 15 <tr> 16 <th>左の内容</th> 17 <td>テキストテキストテキスト</td> 18 </tr> 19 <tr> 20 <th>左の内容</th> 21 <td>テキストテキストテキスト</td> 22 </tr> 23 <tr> 24 <th>左の内容</th> 25 <td><p>テキストテキストテキスト</p></td> 26 </tr> 27 </tbody> 28 </table>
css
1.sp_table *, .sp_table *:before, .sp_table *:after { 2-webkit-box-sizing: border-box; 3box-sizing: border-box; 4} 5.sp_table { 6 width: 100%; 7 border-collapse: collapse; 8 border-top: 1px solid #dbe1e8; 9 border-right: 1px solid #dbe1e8; 10 font-size: 1.4rem; 11} 12.sp_table thead th { 13 padding: 10px 15px; 14 border-right: 1px solid #dbe1e8; 15 border-bottom: 1px solid #dbe1e8; 16 background: #dbe1e8; 17} 18.sp_table thead th:last-child { 19 border-right: 1px solid #dbe1e8; 20} 21.sp_table tbody th { 22 padding: 10px 15px; 23 vertical-align: top; 24 border-left: 1px solid #dbe1e8; 25 border-bottom: 1px solid #dbe1e8; 26 background: #f9fafc; 27 white-space: nowrap; 28 text-align: left; 29} 30.sp_table tbody tr:last-child th { 31 border-bottom: 1px solid #dbe1e8; 32} 33.sp_table tbody td { 34 padding: 10px 15px; 35 vertical-align: top; 36 border-bottom: 1px solid #dbe1e8; 37 border-left: 1px solid #dbe1e8; 38 background: #ffffff; 39} 40.sp_table tr:hover { 41 background-color: #9ab1e5; /* マウスオーバー時の行の背景色 */ 42}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/21 08:16