Osmo Scaling System
Documentation
Webflow
Code
Step 1: Add HTML
HTML structure is not required for this resource.
Step 2: Add CSS
CSS
/* ------------------------- Scaling System by Osmo [https://osmo.supply/] ------------------------- */
/* Desktop */
:root {
--size-unit: 16; /* body font-size in design - no px */
--size-container-ideal: 1440; /* screen-size in design - no px */
--size-container-min: 992px;
--size-container-max: 1920px;
--size-container: clamp(var(--size-container-min), 100vw, var(--size-container-max));
--size-font: calc(var(--size-container) / (var(--size-container-ideal) / var(--size-unit)));
}
/* Tablet */
@media screen and (max-width: 991px) {
:root {
--size-container-ideal: 834; /* screen-size in design - no px */
--size-container-min: 768px;
--size-container-max: 991px;
}
}
/* Mobile Landscape */
@media screen and (max-width: 767px) {
:root {
--size-container-ideal: 550; /* screen-size in design - no px */
--size-container-min: 480px;
--size-container-max: 767px;
}
}
/* Mobile Portrait */
@media screen and (max-width: 479px) {
:root {
--size-container-ideal: 390; /* screen-size in design - no px */
--size-container-min: 320px;
--size-container-max: 479px;
}
}Implementation
To make the scaling system work add the var(--size-font) variable to the font-size of the <body>
body {
font-size: var(--size-font);
}When using a container add the var(--size-container) variable to the max-width of the .container
.container {
max-width: var(--size-container);
}
.container.medium {
max-width: calc(var(--size-container) * 0.85);
}
.container.small {
max-width: calc(var(--size-container) * 0.7);
}Ideal container size
On the --size-container-ideal variable add the size of your design in Figma (no px behind the value)
Max container size
On each viewport you can define a --size-container-max for the scaling system. It will stop after that value is reached.
Resource details
Published
November 22, 2024
Category
Utilities & Scripts
Popularity
5.9K visitors
Need help?
Join Slack