SCSS font-size and line-height mixin

$base-font-size: 16px !default; /* Pixels to ems function */ @function px2em($px) { @return ($px / $base-font-size) * 1em; } /* Font size and line height mixin */ @mixin font-size($font-size, $line-height: false) { font-size: px2em($font-size); /* #{$font-size} */ @if $line-height != false { line-height: ($line-height / $font-size); /* #{$line-height} */ } } /* Usage: p { @include font-size(16px, 32px); } Result: p { font-size: 1em; line-height: 2; } */

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.