scss 响应字体大小混合

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss 响应字体大小混合相关的知识,希望对你有一定的参考价值。

/* --------------------------
 * RESPONSIVE FONT SIZE
 * -------------------------- */

/// Viewport sized typography with minimum and maximum values
///
/// @author Eduardo Boucas (@eduardoboucas)
///
/// @param {Number}   $responsive  - Viewport-based size
/// @param {Number}   $min         - Minimum font size (px)
/// @param {Number}   $max         - Maximum font size (px)
///                                  (optional)
/// @param {Number}   $fallback    - Fallback for viewport-
///                                  based units (optional)
///
/// @example scss - 5vw font size (with 50px fallback), 
///                 minumum of 35px and maximum of 150px
///  @include responsive-font(5vw, 35px, 150px, 50px);

@mixin sr-responsive-font($responsive, $min, $max: false, $fallback: false) {
  $responsive-unitless: $responsive / ($responsive - $responsive + 1);
  $dimension: if(unit($responsive) == 'vh', 'height', 'width');
  $min-breakpoint: $min / $responsive-unitless * 100;
  
  @media (max-#{$dimension}: #{$min-breakpoint}) {
    font-size: $min;
  }
  
  @if $max {
    $max-breakpoint: $max / $responsive-unitless * 100;
    
    @media (min-#{$dimension}: #{$max-breakpoint}) {
      font-size: $max;
    }
  }
  
  @if $fallback {
    font-size: $fallback;
  }
  
  font-size: $responsive;
}

以上是关于scss 响应字体大小混合的主要内容,如果未能解决你的问题,请参考以下文章

scss 响应字体大小

用于小型和大型(流体/响应)列的 Zurb Foundation 4 SCSS 混合

scss 响应式字体大小(адаптивныйшрифт)

带有 rem 的响应式排版 - 以 % 或 px 为单位的基线字体大小?

scss 响应性的混合

scss 响应断点混合