クラス'table-hover'のテーブルがあります。デフォルトのホバーカラーは白/ライトグレーです。この色を変更するにはどうすればよいですか?
ドミナントスタイルシートに以下を追加して、デフォルトを上書きしてみました
.table-hover tbody tr:hover > th {
background-color: #D1D119;
}
残念ながら、上記は機能しません
クラス'table-hover'のテーブルがあります。デフォルトのホバーカラーは白/ライトグレーです。この色を変更するにはどうすればよいですか?
ドミナントスタイルシートに以下を追加して、デフォルトを上書きしてみました
.table-hover tbody tr:hover > th {
background-color: #D1D119;
}
残念ながら、上記は機能しません
これを試してみてください:
.table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
background-color: #color;
}
これは、それをimoで行う最も簡単な方法であり、私にとってはうまくいきました。
.table-hover tbody tr:hover td {
background: aqua;
}
見出しの色を行と同じホバー色に変更する理由はわかりませんが、変更する場合は、上記の解決策を使用できます。あなたがただtが欲しいなら
これは私のために働いた:
.table tbody tr:hover td, .table tbody tr:hover th {
background-color: #eeeeea;
}
HTMLコード:
<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>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
</tbody>
CSSコード
.table-hover thead tr:hover th, .table-hover tbody tr:hover td {
background-color: #D1D119;
}
cssコードは次のことを示しています。
行の上にマウスを置く:
.table-hover> thead> tr:hover
thの背景色が#D1D119に変わります
th
tbodyでも同じアクションが発生します
.table-hover tbody tr:hover td
これは、gruntまたはその他のタスクランナーを介してコンパイルされたブートストラップv4用です。
$table-hover-bg
ホバーでハイライトを設定するには、変更する必要があります
$table-cell-padding: .75rem !default;
$table-sm-cell-padding: .3rem !default;
$table-bg: transparent !default;
$table-accent-bg: rgba(0,0,0,.05) !default;
$table-hover-bg: rgba(0,0,0,.075) !default;
$table-active-bg: $table-hover-bg !default;
$table-border-width: $border-width !default;
$table-border-color: $gray-lighter !default;
.table-hover tbody tr:hover td {
background: #ffffff;
}
試す:
.table-hover > tbody > tr.active:hover > th {
background-color: #color;
}
私にとって、@pvskisteak5の回答は「ちらつき効果」を引き起こしました。これを修正するには、以下を追加します。
.table-hover tbody tr:hover,
.table-hover tbody tr:hover td,
.table-hover tbody tr:hover th{
background:#22313F !important;
color:#fff !important;
}
.table-hover tbody tr:hover td {
background: aqua;
}
これは私がこれまでに考えられる最良の解決策です。それはそのようなシーンで完璧に機能します
ブートストラップで使用される「CSSカスタムプロパティ」を上書きする必要があることがわかりましたbs-table-accent-bg
...
.table-hover > tbody > tr:hover { --bs-table-accent-bg: #f8f8f8; }
パスは、ブートストラップ自体が使用するものです。私はそれをページの検査から取った。
他のソリューションと同じように実行した場合、ブートストラップがすでに適用されているものよりもハイライトを明るくすることができなかったためです。このように機能します(つまり、ホバーカラーを明るくすることができます)。
デフォルトのテーブルホバークラスを変更する代わりに、新しいクラス(anotherhover)を作成し、この効果が必要なテーブルに適用します。
以下のようにコーディングします。
.anotherhover tbody tr:hover td { background: CornflowerBlue; }
これはいくつかの方法で行うことができます。
// Your variable overrides
$table-hover-bg: #d00; // what's that you need
$table-striped-bg: #fff;
// Bootstrap and its default variables
@import "node_modules/bootstrap/scss/bootstrap";
.table {
--bs-table-hover-bg: #d00;
}
また
#thetable tr:hover, #thetable tr td:hover {
background-color: #d00;
}
たとえば、Bootstrapの.table-hover
クラスを試して、ホバー可能な行を実装します。
<table class="table table-hover">
...
</table>