ホバー時に強調表示する必要がある各行にリンクを含むテーブルがあります(tr bgcolorとリンクの両方)。次のコードを使用してJavaScriptでこれを行うことができます:
<style type="text/css">
<!--
.style1 a:link, .style2 a:visited {
color: black;
text-decoration: none;
}
-->
</style>
<table class="style1" width=50%>
<tr onMouseOver="document.getElementById('test').style.color='white'; this.style.backgroundColor='blue';"
onMouseOut="document.getElementById('test').style.color='black'; this.style.backgroundColor='transparent';"
onClick="location.href='foo.html'">
<td><a href="foo.html"><span id="test">link lala</span></a></td>
</tr>
</table>
しかし、私はcssでそれをやりたいです。
私は次のことを試しました:
<style type="text/css">
<!--
.style2 tr:hover {
background-color: blue;
}
.style2 {
color: black;
}
.style2 a:link, .style2 a:visited {
color: black;
text-decoration: none;
}
.style2 a:hover {
color: white;
}
-->
</style>
<table class="style2" width=50%>
<tr>
<td><a href="foo.html">link lala</a></td>
</tr>
</table>
ただし、リンクのホバーは、マウスがリンクの上にある場合にのみ機能します(tr全体の上ではありません)。実際のリンクをクリックすることによってのみ機能するリンクにも問題があります (tr 行全体ではありません)。
これは、css (少なくとも同時ホバー) のみを使用して実行できると確信しています。少し手伝ってくれませんか?
ありがとうございました