Skip to content

Instantly share code, notes, and snippets.

@JawsomeJason
Created October 20, 2018 20:49
Show Gist options
  • Save JawsomeJason/1400133dddd18d76fbe86cffc5f27b09 to your computer and use it in GitHub Desktop.
Save JawsomeJason/1400133dddd18d76fbe86cffc5f27b09 to your computer and use it in GitHub Desktop.
LESS Mixin to easily create fluid typography based on viewport information
// see https://css-tricks.com/snippets/css/fluid-typography/ for 🤯
.viewport-fluid(@property, @from, @to, @screen-min: @screen-sm, @screen-max: @screen-lg, @viewport-unit: vw) {
@{property}: @from;
@media (min-width: @screen-min) {
@{property}: calc(
@from + unit(@to - @from) * ((~"100@{viewport-unit}" - @screen-min) / unit(@screen-max - @screen-min))
);
}
@media (min-width: @screen-max) {
@{property}: @to;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment