Skip to content

Instantly share code, notes, and snippets.

@ehgoodenough
Created October 8, 2019 17:03
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 ehgoodenough/e85054ee7e6dc052e805448b8bec0b40 to your computer and use it in GitHub Desktop.
Save ehgoodenough/e85054ee7e6dc052e805448b8bec0b40 to your computer and use it in GitHub Desktop.
Fits your css rem into a viewport responsive aspect-ratio.
:root {
.aspect-ratio(16, 9);
}
.aspect-ratio(@width, @height) {
@media(min-aspect-ratio: @width ~"/" @height) {
font-size: ((@width / @height)* 100vh) / @width;
}
@media(max-aspect-ratio:@width ~"/" @height) {
font-size: ((@height / @width) * 100vw) / @height;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment