nth-childのような~何番目を指定できる便利なセレクタがたくさんありますが、
それ以外にも便利なセレクタが存在します。
1. :matches()
■css
box_01 h1,
box_01 h2,
box_02 h1,
box_02 h2,
:matches(box_01, box_02) :matches(h1, h2){}
:matches()を使えば、シンプルにcssを記述することができます。
1 2 3 4 5 6 |
:-webkit-any() { color: #0060e6; } :-moz-any() { color: #0060e6; } |
:matches()はSafariのみ対応していますが、
Firefox・Chromeなどでは:any()擬似クラスを使うことになっています。
コメント