More actions
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
.template-flexbox { | .template-flexbox { | ||
display: flex; | |||
gap: var(--template-flexbox-gap); | |||
flex-wrap: wrap; | |||
flex-direction: var(--template-flexbox-direction); | |||
--template-flexbox-columns: 3; /* Default columns count */ | |||
} | } | ||
/* Flex items */ | |||
.template-flexbox-item { | .template-flexbox-item { | ||
--template-flexbox-item-span: 1; /* Default span is 1 */ | |||
--template-flexbox-item-width: calc(100% / var(--template-flexbox-columns) - (var(--template-flexbox-gap) * (var(--template-flexbox-columns) - 1) / var(--template-flexbox-columns))); | |||
flex-basis: var(--template-flexbox-item-width); | |||
flex-grow: 0; /* Flex-grow shouldn't be used unless you want to allow stretching */ | |||
flex-shrink: 0; /* Prevent shrinking */ | |||
} | } | ||
/* Media query for different screen sizes */ | |||
@media (max-width: 1120px) { | @media (max-width: 1120px) { | ||
.template-flexbox { | |||
--template-flexbox-columns: 2 !important; | |||
} | |||
} | } | ||
@media (max-width: 640px) { | @media (max-width: 640px) { | ||
.template-flexbox { | |||
--template-flexbox-columns: 1 !important; | |||
} | |||
} | } |
Revision as of 15:07, 28 December 2024
.template-flexbox { display: flex; gap: var(--template-flexbox-gap); flex-wrap: wrap; flex-direction: var(--template-flexbox-direction); --template-flexbox-columns: 3; /* Default columns count */ } /* Flex items */ .template-flexbox-item { --template-flexbox-item-span: 1; /* Default span is 1 */ --template-flexbox-item-width: calc(100% / var(--template-flexbox-columns) - (var(--template-flexbox-gap) * (var(--template-flexbox-columns) - 1) / var(--template-flexbox-columns))); flex-basis: var(--template-flexbox-item-width); flex-grow: 0; /* Flex-grow shouldn't be used unless you want to allow stretching */ flex-shrink: 0; /* Prevent shrinking */ } /* Media query for different screen sizes */ @media (max-width: 1120px) { .template-flexbox { --template-flexbox-columns: 2 !important; } } @media (max-width: 640px) { .template-flexbox { --template-flexbox-columns: 1 !important; } }