LoginSignup
0
0

More than 1 year has passed since last update.

CSSで同じ要素の複数のクラスを条件にスタイルを付ける

Posted at

以下のように同じ要素内に2つのクラスを持つ要素に対してだけ、スタイルを付けたいとなったときに、「あれ?」となった...

<div class="hoge fuga"></div>
  • ダメな例)
    これだと「hogeというクラスを親要素のfugaというクラスがついた要素に対してクラスを付ける」ということになってしまう。
<style>
.hoge .fuga {
  color: red;
}
</style>
  • 良い例)
    .hoge.fugaの間にスペースを入れずに連結して記述する
<style>
.hoge.fuga {
  color: red;
}
</style>
0
0
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
0
0