0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

scssの変数をcssの変数に入れる

0
Posted at

以下のようにすると入らない。

$base0: #839496;

:root {
  --base0: $base0;
}

変数展開っぽく書くと展開される。

$base0: #839496;

:root {
  --base0: #{$base0};
}

インターポレーションというらしい、変数展開じゃないのか:rolling_eyes:

ダークモード対応

ダークモードに対応するときなどには、以下のようになる。

:root {
  --base3: #{$base3};
  --base2: #{$base2};
  --base1: #{$base1};
  --base0: #{$base0};
  --base00: #{$base00};
}

@media (prefers-color-scheme: dark) {
  :root {
    --base3: #{$base03};
    --base2: #{$base02};
    --base1: #{$base01};
    --base0: #{$base00};
    --base00: #{$base0};
  }
}

カラースキームから持ってきたやつを入れればいいだけなので、簡単・便利・安心。

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?