Zloutek1
Zloutek1

Reputation: 55

css grid calculate fraction from variable

I have a div with display: grid;

I am using css properties / variables to have a dynamic website, which I then update via javascript.

I managed to achieve this using scss

grid-template-columns: var(--user-column-width) $days-shown + unquote('fr');

The question is, is it possible to have something like

grid-template-columns: var(--user-column-width) var(--days-shown)fr;

I did not yet succeed in combining the variable and fractions together. So if possible, how can it be done?

Thanks

Upvotes: 0

Views: 556

Answers (1)

chriskirknielsen
chriskirknielsen

Reputation: 2929

You can use calc(1fr * var(--days-shown)) to achieve this, as long as --days-show is unitless.

Upvotes: 1

Related Questions