0
0

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 1 year has passed since last update.

calc()内でscssの変数表記を使いたい

Posted at

ちょろい内容ですがいっつも書き方忘れるのでメモ。
calc()内でscssの変数表記を行っても、変数展開されないのでその時のTips

// 両端にmarginで余白を取り、widthはそれを引いた値にしたい

// NG
$margin-width: 20px;
.sample {
  width: calc(100% - $margin-width * 2); // この書き方ではだめ
  margin: 0 $margin-width;
}

// OK
$margin-width: 20px;
.sample {
  width: calc(100% - #{$margin-width} * 2); // #{}で囲む
  margin: 0 $margin-width;
}

地味に困ってる方いるんじゃないでしょうか。。。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?