Last active
September 6, 2016 17:24
-
-
Save delphinpro/3b0bd7ca0549e64a0f4bd929f15a4bd5 to your computer and use it in GitHub Desktop.
Адаптивный размер шрифта.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Адаптивный размер шрифта. | |
/// В параметрах миксина указывается минимальный и максимальный размеры шрифта. | |
@function vw($pixel, $defaultWidth: 1920px) { | |
@return $pixel * (100 / $defaultWidth) * 1vw; | |
} | |
@function calcVw($minPixel, $pixel) { | |
$addPixel: vw($pixel - $minPixel); | |
@return #{"calc(#{$minPixel} + #{$addPixel})"}; | |
} | |
@mixin fontSizeAdaptive($minPixel, $pixel) { | |
font-size: $minPixel; | |
font-size: calcVw($minPixel, $pixel); | |
} | |
// example usage | |
// | |
// .selector { | |
// @include fontSizeAdaptive(12px, 20px); | |
// } | |
// | |
// compiled to | |
// | |
// .selector { | |
// font-size: 12px; | |
// font-size: calc(12px + 0.42vw); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment