Skip to content

Instantly share code, notes, and snippets.

@webbingstudio
Last active October 30, 2016 11:16
Show Gist options
  • Save webbingstudio/a409a38d17f647389454822a640e4c0d to your computer and use it in GitHub Desktop.
Save webbingstudio/a409a38d17f647389454822a640e4c0d to your computer and use it in GitHub Desktop.
ボックスの文字サイズと行間を反映した上下余白をremで返すmixin ref: http://qiita.com/webbingstudio@github/items/b607869bedec12eea961
// px高さと文字サイズから必要な余白を計算し、remで返す
@mixin box-spacing( $height: 30, $font-size: 16, $line-height: 1.35, $border-top: 0, $border-bottom: 0, $rem: 16 ) {
padding-top: ( ( ( $height - ( $border-top + $border-bottom ) - ( $font-size * $line-height ) ) / 2 ) / $rem ) * 1rem;
padding-bottom: ( ( ( $height - ( $border-top + $border-bottom ) - ( $font-size * $line-height ) ) / 2 ) / $rem ) * 1rem;
}
.example {
@include box-spacing( 44, 16, 1.5, 3, 3 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment