FluidCols (l--fluidCols)
l--fluidCols is a breakpoint-independent multi-column class where columns automatically wrap before they shrink below the specified minimum width.
CSS
/*
Memo: オーバーフロー回避のため、 min({cols}, 100%) とする。
*/
.l--fluidCols {
--cols: var(--sz--min);
--autoMode: auto-fit;
display: grid;
grid-template-columns: repeat(var(--autoMode), minmax(min(var(--cols), 100%), 1fr));
} Lism Component
Import
import { FluidCols } from 'lism-css/react'; Props
| Property | Description |
|---|---|
cols --cols | Specifies the minimum width each column should maintain. |
autoFill --autoMode | Switches the auto-wrap mode to auto-fill. |
Usage
Setting the size with --cols
↓
Setting the size with
--colsItem A
Item B
Item C
Item D
Item E
Item F
リサイズ可能
<FluidCols cols="16em" g="20"> <Lism as="div" p="20" bd>Item A</Lism> <Lism as="div" p="20" bd>Item B</Lism> <Lism as="div" p="20" bd>Item C</Lism> <Lism as="div" p="20" bd>Item D</Lism> <Lism as="div" p="20" bd>Item E</Lism> <Lism as="div" p="20" bd>Item F</Lism></FluidCols>Using auto-fill
In l--fluidCols, you can control the first argument of the repeat() function in grid-template-columns via --autoMode. (The default is auto-fit.)
Setting --autoMode: auto-fill (autoFill) changes the behavior when there are only a few items.
↓
Using
cols=12em with auto-fillauto-fill
auto-fill
auto-fit
auto-fit
リサイズ可能
<FluidCols cols="12em" autoFill g="20" fz="s"> <Lism as="div" p="20" bd>auto-fill</Lism> <Lism as="div" p="20" bd>auto-fill</Lism></FluidCols><FluidCols cols="12em" g="20" fz="s"> <Lism as="div" p="20" bd>auto-fit</Lism> <Lism as="div" p="20" bd>auto-fit</Lism></FluidCols>