LoginSignup
5
4

More than 5 years have passed since last update.

CSS(SCSS)で直下の子セレクタを複数指定

Posted at

cssで直下の子セレクタを複数指定したいときに(この場合は a , span の2種類の子セレクタ)

style.scss
 .hoge {
    > a, span {
        color: red;
    }
 }

みたいにやってはみたが、 span においては孫セレクタまでcssが効いてしまっていた。
よく考えてみると、

style.scss
 .hoge {
    > a, > span {
        color: red;
    }
 }

とやる必要があったみたい。
カンマでセレクタが区切られているのだから、当たり前っちゃ当たり前だったけど、少し悩んでしまいました。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4