Flex
Ceev ceev tswj qhov kev teeb tsa, kev sib dhos, thiab qhov loj ntawm kab kab ke, kev taw qhia, cov khoom siv, thiab ntau ntxiv nrog rau tag nrho cov suite ntawm cov khoom siv flexbox teb. Rau kev siv ntau dua, kev cai CSS tej zaum yuav tsim nyog.
Siv display
cov khoom siv hluav taws xob los tsim lub thawv flexbox thiab hloov cov ntsiab lus ntawm cov menyuam yaus rau hauv cov khoom flex. Flex ntim thiab cov khoom tuaj yeem hloov kho ntxiv nrog cov khoom flex ntxiv.
Teb variations kuj muaj rau .d-flex
thiab .d-inline-flex
.
.d-flex
.d-inline-flex
.d-sm-flex
.d-sm-inline-flex
.d-md-flex
.d-md-inline-flex
.d-lg-flex
.d-lg-inline-flex
.d-xl-flex
.d-xl-inline-flex
Teem cov kev taw qhia ntawm cov khoom flex nyob rau hauv ib lub thawv flex nrog cov khoom siv kev taw qhia. Feem ntau koj tuaj yeem tshem tawm cov chav kawm kab rov tav ntawm no raws li qhov browser default yog row
. Txawm li cas los xij, koj tuaj yeem ntsib cov xwm txheej uas koj xav tau los teeb tsa tus nqi no (xws li cov lus teb layouts).
Siv .flex-row
los teeb tsa kab rov tav kev taw qhia (qhov browser default), lossis .flex-row-reverse
pib txoj kab rov tav los ntawm sab nraud.
Siv .flex-column
los teeb tsa txoj kab ntsug, lossis .flex-column-reverse
pib txoj kab ntsug ntawm sab nraud.
Teb variations kuj muaj rau flex-direction
.
.flex-row
.flex-row-reverse
.flex-column
.flex-column-reverse
.flex-sm-row
.flex-sm-row-reverse
.flex-sm-column
.flex-sm-column-reverse
.flex-md-row
.flex-md-row-reverse
.flex-md-column
.flex-md-column-reverse
.flex-lg-row
.flex-lg-row-reverse
.flex-lg-column
.flex-lg-column-reverse
.flex-xl-row
.flex-xl-row-reverse
.flex-xl-column
.flex-xl-column-reverse
Siv justify-content
cov khoom siv hluav taws xob ntawm flexbox ntim los hloov cov kev sib tw ntawm cov khoom flex ntawm lub ntsiab axis (x-axis pib, y-axis yog flex-direction: column
). Xaiv los ntawm start
(browser default), end
, center
, between
, lossis around
.
Teb variations kuj muaj rau justify-content
.
.justify-content-start
.justify-content-end
.justify-content-center
.justify-content-between
.justify-content-around
.justify-content-sm-start
.justify-content-sm-end
.justify-content-sm-center
.justify-content-sm-between
.justify-content-sm-around
.justify-content-md-start
.justify-content-md-end
.justify-content-md-center
.justify-content-md-between
.justify-content-md-around
.justify-content-lg-start
.justify-content-lg-end
.justify-content-lg-center
.justify-content-lg-between
.justify-content-lg-around
.justify-content-xl-start
.justify-content-xl-end
.justify-content-xl-center
.justify-content-xl-between
.justify-content-xl-around
Siv align-items
cov khoom siv hluav taws xob ntawm cov thawv flexbox los hloov cov kev sib tw ntawm cov khoom flex ntawm tus ntoo khaub lig axis (y-axis pib, x-axis yog flex-direction: column
). Xaiv los ntawm start
, end
, center
, baseline
, lossis stretch
(browser default).
Teb variations kuj muaj rau align-items
.
.align-items-start
.align-items-end
.align-items-center
.align-items-baseline
.align-items-stretch
.align-items-sm-start
.align-items-sm-end
.align-items-sm-center
.align-items-sm-baseline
.align-items-sm-stretch
.align-items-md-start
.align-items-md-end
.align-items-md-center
.align-items-md-baseline
.align-items-md-stretch
.align-items-lg-start
.align-items-lg-end
.align-items-lg-center
.align-items-lg-baseline
.align-items-lg-stretch
.align-items-xl-start
.align-items-xl-end
.align-items-xl-center
.align-items-xl-baseline
.align-items-xl-stretch
Siv align-self
cov khoom siv hluav taws xob ntawm cov khoom flexbox los hloov lawv cov kev sib tw ntawm tus ntoo khaub lig axis (y-axis pib, x-axis yog flex-direction: column
). Xaiv los ntawm tib cov kev xaiv xws li align-items
: start
, end
, , center
, baseline
, lossis stretch
(browser default).
Teb variations kuj muaj rau align-self
.
.align-self-start
.align-self-end
.align-self-center
.align-self-baseline
.align-self-stretch
.align-self-sm-start
.align-self-sm-end
.align-self-sm-center
.align-self-sm-baseline
.align-self-sm-stretch
.align-self-md-start
.align-self-md-end
.align-self-md-center
.align-self-md-baseline
.align-self-md-stretch
.align-self-lg-start
.align-self-lg-end
.align-self-lg-center
.align-self-lg-baseline
.align-self-lg-stretch
.align-self-xl-start
.align-self-xl-end
.align-self-xl-center
.align-self-xl-baseline
.align-self-xl-stretch
Siv cov .flex-fill
chav kawm ntawm cov nus muag cov ntsiab lus kom yuam lawv mus rau hauv qhov dav sib npaug thaum noj txhua qhov chaw muaj kab rov tav. Tshwj xeeb tshaj yog pab tau rau vaj huam sib luag-dav, los yog kev ncaj ncees, navigation.
Teb variations kuj muaj rau flex-fill
.
.flex-fill
.flex-sm-fill
.flex-md-fill
.flex-lg-fill
.flex-xl-fill
Siv.flex-grow-*
cov khoom siv hluav taws xob los hloov cov khoom flex lub peev xwm loj hlob los sau qhov chaw muaj. Hauv qhov piv txwv hauv qab no, cov .flex-grow-1
ntsiab lus siv txhua qhov chaw uas nws tuaj yeem ua tau, thaum tso cai rau ob qho khoom ntxiv rau lawv qhov chaw tsim nyog.
Siv .flex-shrink-*
cov khoom siv hluav taws xob los hloov cov khoom flex lub peev xwm kom ntsws yog tias tsim nyog. Hauv qhov piv txwv hauv qab no, qhov thib ob flex khoom nrog .flex-shrink-1
raug yuam kom qhwv nws cov ntsiab lus rau ib kab tshiab, "shrinking" kom tso cai ntau qhov chaw rau cov khoom flex yav dhau los nrog .w-100
.
Teb variations kuj muaj rau flex-grow
thiab flex-shrink
.
.flex-{grow|shrink}-0
.flex-{grow|shrink}-1
.flex-sm-{grow|shrink}-0
.flex-sm-{grow|shrink}-1
.flex-md-{grow|shrink}-0
.flex-md-{grow|shrink}-1
.flex-lg-{grow|shrink}-0
.flex-lg-{grow|shrink}-1
.flex-xl-{grow|shrink}-0
.flex-xl-{grow|shrink}-1
Flexbox tuaj yeem ua qee yam zoo nkauj heev thaum koj sib xyaw flex kev sib raug zoo nrog cov npoo pib. Hauv qab no yog peb qhov piv txwv ntawm kev tswj cov khoom flex ntawm nws pib margins: lub neej ntawd (tsis muaj qhov pib pib), thawb ob yam khoom mus rau sab xis ( .mr-auto
), thiab thawb ob yam khoom mus rau sab laug (.ml-auto
).
Hmoov tsis zoo, IE10 thiab IE11 tsis zoo txhawb kev pib pib ntawm cov khoom flex uas nws niam txiv tsis justify-content
muaj nuj nqis. Saib cov lus teb StackOverflow no kom paub meej ntxiv.
Vertically txav ib yam khoom flex mus rau saum lossis hauv qab ntawm lub thawv los ntawm kev sib xyaw align-items
, flex-direction: column
, thiab margin-top: auto
lossis margin-bottom: auto
.
Hloov cov khoom flex li cas qhwv hauv lub thawv flex. Xaiv los ntawm tsis muaj wrapping txhua (qhov browser default) nrog .flex-nowrap
, wrapping nrog .flex-wrap
, lossis thim rov qab wrapping nrog .flex-wrap-reverse
.
Teb variations kuj muaj rau flex-wrap
.
.flex-nowrap
.flex-wrap
.flex-wrap-reverse
.flex-sm-nowrap
.flex-sm-wrap
.flex-sm-wrap-reverse
.flex-md-nowrap
.flex-md-wrap
.flex-md-wrap-reverse
.flex-lg-nowrap
.flex-lg-wrap
.flex-lg-wrap-reverse
.flex-xl-nowrap
.flex-xl-wrap
.flex-xl-wrap-reverse
Hloov qhov pom kev txiav txim ntawm cov khoom flex tshwj xeeb nrog ib txhais tes ntawm order
cov khoom siv. Peb tsuas yog muab cov kev xaiv los ua ib yam khoom ua ntej lossis zaum kawg, nrog rau kev rov pib siv DOM xaj. Raws li order
yuav siv tus nqi sib npaug (piv txwv li, 5
), ntxiv kev cai CSS rau ib qho txiaj ntsig ntxiv uas xav tau.
Teb variations kuj muaj rau order
.
.order-0
.order-1
.order-2
.order-3
.order-4
.order-5
.order-6
.order-7
.order-8
.order-9
.order-10
.order-11
.order-12
.order-sm-0
.order-sm-1
.order-sm-2
.order-sm-3
.order-sm-4
.order-sm-5
.order-sm-6
.order-sm-7
.order-sm-8
.order-sm-9
.order-sm-10
.order-sm-11
.order-sm-12
.order-md-0
.order-md-1
.order-md-2
.order-md-3
.order-md-4
.order-md-5
.order-md-6
.order-md-7
.order-md-8
.order-md-9
.order-md-10
.order-md-11
.order-md-12
.order-lg-0
.order-lg-1
.order-lg-2
.order-lg-3
.order-lg-4
.order-lg-5
.order-lg-6
.order-lg-7
.order-lg-8
.order-lg-9
.order-lg-10
.order-lg-11
.order-lg-12
.order-xl-0
.order-xl-1
.order-xl-2
.order-xl-3
.order-xl-4
.order-xl-5
.order-xl-6
.order-xl-7
.order-xl-8
.order-xl-9
.order-xl-10
.order-xl-11
.order-xl-12
Siv align-content
cov khoom siv hluav taws xob ntawm cov thawv flexbox txhawm rau kho cov khoom flex ua ke ntawm tus ntoo khaub lig. Xaiv los ntawm start
(browser default), end
, center
, between
, around
, lossis stretch
. Txhawm rau ua kom pom cov khoom siv hluav taws xob no, peb tau tswj hwm flex-wrap: wrap
thiab nce tus naj npawb ntawm cov khoom flex.
Tau taub hau! Cov cuab yeej no tsis cuam tshuam rau ib kab ntawm cov khoom flex.
Teb variations kuj muaj rau align-content
.
.align-content-start
.align-content-end
.align-content-center
.align-content-around
.align-content-stretch
.align-content-sm-start
.align-content-sm-end
.align-content-sm-center
.align-content-sm-around
.align-content-sm-stretch
.align-content-md-start
.align-content-md-end
.align-content-md-center
.align-content-md-around
.align-content-md-stretch
.align-content-lg-start
.align-content-lg-end
.align-content-lg-center
.align-content-lg-around
.align-content-lg-stretch
.align-content-xl-start
.align-content-xl-end
.align-content-xl-center
.align-content-xl-around
.align-content-xl-stretch