擬似クラス
:hover
- 主にマウスカーソルの動作に対して使われる擬似クラスです
- マウスカーソルがホバーした時(要素の上に乗った時)にスタイルを反映させる
<p><a href="#">テキストリンク</a></p>
a { color: inherit; text-decoration: none; } a:hover { color: #ff3700; text-decoration: underline; }
:hover
- :nth-child()
- ( )内は、evenや2nで偶数の子要素にスタイルを反映させる
<ul> <li>アイテム1</li> <li>アイテム2</li> <li>アイテム3</li> <li>アイテム4</li> <li>アイテム5</li> <li>アイテム6</li> </ul>
li:nth-child(even) { color: #ff3700; }