0

CSS ミックスイン

.rhythm(@font-scale, @margin-top : false, @margin-bottom : false)
when (@font-scale > 0) {
    @new-font-size: round(@base-font-size * pow(@base-scale-factor, @font-scale));
    font-size: @new-font-size;
    line-height: ceil((@new-font-size / (@base-line-height * @base-font-size))) * (@base-line-height * @base-font-size);
}

.rhythm(@font-scale, @margin-top : false, @margin-bottom : false)
when (@font-scale = 0) {
    @new-font-size: round(@base-font-size * pow(@base-scale-factor, @font-scale));
    font-size: @new-font-size;
    line-height: ceil((@new-font-size / (@base-line-height * @base-font-size))) * (@base-line-height * @base-font-size);
}

.rhythm(@font-scale, @margin-top : false, @margin-bottom : false)
when (isnumber(@margin-top)) {
    margin-top: @base-font-size * (@base-line-height * @margin-top);
}

.rhythm(@font-scale, @margin-top : false, @margin-bottom : false)
when (isnumber(@margin-bottom)) {
    margin-bottom: @base-font-size * (@base-line-height * @margin-bottom);
}

使用法:

p {
    .rhythm(4, 1, 2);
}

出力:

p {
  font-size: NaN;
  line-height: NaN;
  margin-top: 24;
  margin-bottom: 48;
}

誰かがフォントサイズでこの問題を理解するのを手伝ってくれますか?

4

1 に答える 1