🚀

Update available

We just released a new resource or update, refresh the Vault to access the latest version.

Cancel

Refresh now

Harri

Profile Picture

Harri

Lemke

Osmo Scaling System
Osmo Scaling System
Osmo Scaling System

Documentation

Webflow

Code

Step 1: Add HTML

HTML structure is not required for this resource.

Step 2: Add CSS

CSS

Copy
/* ------------------------- 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);
}
Copy

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);
}
Copy

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.

Live preview

Osmo Robot AI

Copy context for AI

Beta

Webflow

HTML/CSS/JS

Copy share link

Resource details

  • Published

    November 22, 2024

  • Category

    Utilities & Scripts

  • Popularity

    5.9K visitors

  • Need help?

    Join Slack

System
Resize
Typography
CSS
Calc
Variables
Layout

Watch the video

Hide the video

Dennis SnellenbergDennis Snellenberg

Creator Credits

We always strive to credit creators as accurately as possible. While similar concepts might appear online, we aim to provide proper and respectful attribution.

s