Skip to content

Instantly share code, notes, and snippets.

@delphinpro
Last active September 6, 2016 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delphinpro/3b0bd7ca0549e64a0f4bd929f15a4bd5 to your computer and use it in GitHub Desktop.
Save delphinpro/3b0bd7ca0549e64a0f4bd929f15a4bd5 to your computer and use it in GitHub Desktop.
Адаптивный размер шрифта.
/// Адаптивный размер шрифта.
/// В параметрах миксина указывается минимальный и максимальный размеры шрифта.
@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