Skip to Content

Layout


Basic length based property to work with layout.

Almost all property which accept length value work in similar fashion.You can use both full semantic or shorthand.

padding(p),margin(m),gap(g),width(w),height(h),border-width(bw), line-height(lh),letter-spacing(les),border-radius(br),text-intent(ti), text-shadow(txs),box-shadow(bxs),top(t),bottom(btm),right(r),left(l),outline-width(olw) background-size(bgs),background-position(bgp),inline-size(is),block-size(no shorthand), margin-block(no shorthand),padding-block(no shorthand)
ClassnameShorthandCompiled Style
width-200pxw-200pxwidth:200px
max-width-960pxxw-960pxmax-width:960px
min-width-600pxmw-600pxmin-width:600px
margin-2remm-2remmargin:2rem
margin-2rem-12pxm-2rem-12pxmargin:2rem 12px
margin--2rem-12pxm--2rem-12pxmargin:-2rem 12px
margin--2rem--12pxm--2rem--12pxmargin:-2rem -12px
margin-12px-0px-12px--8pxm-12px-0px-12px--8pxmargin:12px 0px 12px -8px
margin-x-12pxmx-12pxmargin-right:12px; margin-left:12px
margin-x-4mx-4margin-right:1rem; margin-left:1rem
border-radius-10pxbr-10pxborder-radius:10px
box-shadow--1px-0px-2px-4px-black/7bxs--1px-0px-2px-4px-black/7box-shadow:-1px 0px 2px 4px oklch(from black l c h/0.7 )
text-shadow-1px-1px-4px-blacktxs-1px-1px-4px-blacktext-shadow:1px 1px 4px black )

Numeric VALUE [1-10] used for padding, gap, margin will be compiled to corresponding relative unit in the multiple of 0.25rem * n , eg 4 =>0.25*4=1rem

Usage Eg:-

<h1 class="mx-4 p-32px-24px w-100% mh-200px bgc-primary600/7 c--text-color:gray" > Hello, World </h1>

Non Numeric length Value

ClassnameShorthandCompiled Style
width-max-contentw-xcwidth:max-content
width-min-contentw-mcwidth:min-content
width-fit-contentw-fcwidth:fit-content
width-min(40%,400px)w-min(40%,400px)width:min(40%, 400px)
width-max(40%,400px)w-max(40%,400px)width:max(40%, 400px)
width-clamp(20rem,30vw,70rem)w-clamp(20rem,30vw,70rem)width:clamp(20rem, 30vw, 70rem)

Note:Try to use css-variable as much possible for complex values. for Example

<h1 class=" w--header-width mx-4 p-32px-24px w-100% mh-200px bgc-primary600/7 c--text-color:gray" style="--header-width:clamp(min(10vw, 20rem), 300px, max(90vw, 55rem))" > Hello, World </h1>

Flex and Grid and Box Model

Most common Class names
ClassnameShorthandCompiled Style
display-flexdf or d-fdisplay:flex
gap-16pxg-16pxgap:16px
display-inline-flexdif or d-ifdisplay:inline-flex
display-griddg or d-gdisplay:grid
display-inline-griddig or d-igdisplay:inline-grid
display-blockdb or d-bdisplay:block
display-inline-blockdib or d-ibdisplay:inline-block
display-nonedn or d-ndisplay:none
align-content-startacs or ac-salign-content:start
align-items-centeraic or ai-calign-items:center
align-self-stretchass or as-salign-self:stretch
justify-content-space-betweenjcsb or jc-sbjustify-content:space-between
flex-shrink-0no shorthandflex-shrink:0
flex-basis-200pxfb-200pxflex-basis:200px
flex-grow-0fg-0flex-grow:0
flex-direction-rowfdr or fd-rflex-direction:row
flex-direction-row-reversefdrr or fd-rrflex-direction:row-reverse
flex-direction-columnfdc or fd-cflex-direction:column
flex-direction-column-reversefdcr or fd-crflex-direction:column-reverse
grid-template-columns-repeat-3-1frgtc-repeat-3-1frgrid-template-columns:repeat(3, 1fr)
grid-template-rows-repeat-3-1frgtr-repeat-3-1frgrid-template-rows:repeat(3, 1fr)
grid-template-rows-200px-1frgtr-200px-1frgrid-template-rows:200px 1fr
grid-template-columns-repeat-auto-fill-200pxgtc-repeat-auto-fill-200pxgrid-template-columns:repeat(auto-fill, 200px)
grid-auto-rows-200pxgar-200pxgrid-auto-rows:200px
grid-auto-rows-minmax-100px-autogar-minmax-100px-autogrid-auto-rows:minmax(100px, auto)
grid-column-start-2gcs-2grid-column-start:2
grid-column-end-4gce-4grid-column-end:4
grid-row-start-1grs-1grid-row-start:1
grid-row-end--3gre--3grid-row-end:-3
grid-row-end-span-3gre-span-3grid-row-end:span 3
grid-column-1/2gc-1/2grid-column:1 / 2
grid-column-1/--2gc-1/--2grid-column:1 / -2
grid-row-1/4gr-1/4grid-row:1 / 4
grid-area-1/1/4/2ga-1/1/4/2grid-area:1 / 1 / 4 / 2
<!-- Layout --> <div class="d-g gtc-repeat-3-1fr gap-16px"> <!-- Card --> <div class="bg-white p-20px border-radius-10px shadow-sm d-f fd-c gap-8px"> <h3 class="fs-16px fw-600 color-gray-800">Card Title</h3> <p class="fs-14px color-gray-500">Some description text goes here.</p> <button class="mt-auto bg-blue-500 color-white p-8px-16px border-radius-6px"> Read More </button> </div> ..... </div>

Positioning

ClassnameShorthandCompiled Style
position-absolutepaposition: absolute
position-relativeprposition: relative
position-fixedpfposition: fixed
position-staticpsposition: static
position-stickypstposition: sticky
top-20pxt-20pxtop: 20px
right-20pxr-20pxright: 20px
bottom-20pxbtm-20pxbottom: 20px
left--20pxl--20pxleft: -20px
inset-0i-0inset: 0
overflow-hiddenohoverflow: hidden
overflow-y-autooyaoverflow-y: auto
overflow-x-scrolloxsoverflow-x: scroll
float-rightfrfloat: right
float-leftflfloat: left
clear-leftclclear: left
clear-rightcrclear: right
clear-bothcbclear: both

Note

💡

TIPS You can always use css-variables to handle complex values. for Example

<section class="gtc--panel-grid-area gta--named-grid-areas " style=' --panel-grid-area:repeat(3, [col-start] 1fr [col-end]); --name-grid-areas:"header header header" "sidebar main main" "footer footer footer" ' > Hello, World </section>
Last updated on