FluidCols (l--fluidCols)
l--fluidCols は、カラム要素が指定した幅より小さくならないように自動で折り返す、ブレイクポイントに依存しない段組みクラスです。
CSS
/*
Memo: オーバーフロー回避のため、 min({cols}, 100%) とする。
*/
.l--fluidCols {
--cols: 20rem;
--autoMode: auto-fit;
display: grid;
grid-template-columns: repeat(var(--autoMode), minmax(min(var(--cols), 100%), 1fr));
} Lismコンポーネント
Import
import { FluidCols } from 'lism-css/react'; 専用Props
| プロパティ | 説明 |
|---|---|
cols --cols | カラムが維持する最小幅を指定します。 |
autoFill --autoMode | 自動折り返しのモードをauto-fillに切り替えます。 |
Usage
--colsでサイズを指定する
↓
--colsでサイズを指定するItem 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>auto-fillを使用する
l--fluidColsでは、grid-template-columnsのrepeat関数の第一引数を--autoMode で指定することができます。(デフォルトは auto-fit です。)
--autoMode:auto-fill (autoFill) を指定することで、要素数が少ない時の挙動が代わります。
↓
cols=12em, auto-fill を使用するauto-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>