CSS Calc Formula for the layout
header, main, aside, sidebar {
--columns: 6;
--width: 6;
--initialbasis: calc(var(--width) / var(--columns) * 100%);
--gap: calc((var(--columns) - var(--width)) * 0.05%);
flex-basis: calc(var(--initialbasis) - var(--gap));
}
--width: 6;
--initialbasis: calc(var(--width) / var(--columns) * 100%);
--gap: calc((var(--columns) - var(--width)) * 0.05%);
flex-basis: calc(var(--initialbasis) - var(--gap));
Change the layout by changing value of following elements
| CSS Variable | Description | value |
|---|---|---|
| --columns | Preset by default to be 6 columns | 6 |
| --width | It’s the span of each column | 1-6 |
| --initial basis | It’s the result of width/span dividing the columns in % | x % |
| gap percentage (preset: 0.05%) |
Gap between the columns in % | 0 - x % |
| Flex-basis | It’s the actual width of the columns without the gap | 0 - x % |