Skip to content

Instantly share code, notes, and snippets.

@Nikolasgrizli
Created August 17, 2019 22:54
Show Gist options
  • Save Nikolasgrizli/c19502ab381a67ffc2b5ccfb18e2b5fe to your computer and use it in GitHub Desktop.
Save Nikolasgrizli/c19502ab381a67ffc2b5ccfb18e2b5fe to your computer and use it in GitHub Desktop.
Less fx allows you to make a smooth transition in size any properties relative to the width of the screen (if you're using Less 1.6 or later)
.prop-size-fx(@min-size: 1, @max-size: 2, @min-width: 768, @max-width: 1024, @property: font-size){
@{property} : @max-size * 1px;
@{property} : ~"calc(@{min-size}px + (@{max-size} - @{min-size}) * ((100vw - @{min-width}px) / (@{max-width} - @{min-width})))";
@media screen and (max-width: (@min-width + 1px)) {
@{property} : @min-size * 1px;
}
@media screen and (min-width: (@max-width + 1px)) {
@{property} : @max-size * 1px;
}
}
// example - .prop-size-fx(20,30,768,1024,margin-top);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment