Sisitemu ya sisitemu
Koresha imbaraga zacu zigendanwa-yambere ya flexbox gride kugirango wubake imiterere yuburyo bwose nubunini dukesha sisitemu cumi na zibiri, ibice bitanu byitondewe byitabira, Sass variable na mixins, hamwe nibyiciro byinshi byateganijwe mbere.
Sisitemu ya Bootstrap ikoresha urukurikirane rwibikoresho, umurongo, hamwe ninkingi kugirango bishyire hamwe kandi bihuze ibirimo. Yubatswe na flexbox kandi irasubiza rwose. Hasi nurugero hamwe nuburyo bwimbitse reba uburyo gride ihurira hamwe.
Gishya kuri cyangwa utamenyereye flexbox? Soma iyi CSS Amayeri ya flexbox yubuyobozi bwinyuma, ijambo, amabwiriza, hamwe nibice bya kode.
Urugero ruvuzwe haruguru rurema inkingi eshatu zingana-ubugari kumurongo muto, uringaniye, nini, nibindi bikoresho binini ukoresheje ibyiciro byateganijwe mbere ya gride. Izo nkingi zegeranye kurupapuro hamwe nababyeyi .container
.
Kumena, dore uko ikora:
- Ibirimwo bitanga uburyo bwo gushira hamwe no gutambutsa ibirimo kurubuga rwawe. Koresha
.container
ubugari bwa pigiseli isubiza cyangwa.container-fluid
kuriwidth: 100%
byose byerekanwe hamwe nubunini bwibikoresho. - Imirongo ni ibipfunyika byinkingi. Buri nkingi ifite horizontal
padding
(bita gutter) yo kugenzura umwanya hagati yabo. Ibipadding
noneho birwanya kumurongo hamwe nintera mbi. Ubu buryo, ibikubiye mu nkingi zawe byose bigaragara neza kuruhande rwibumoso. - Imiterere ya gride, ibirimo bigomba gushyirwa mumirongo kandi inkingi gusa zishobora kuba abana b'imirongo.
- Turashimira flexbox, grid inkingi idafite isobanura
width
izahita itondekanya nkubugari bungana. Kurugero, ingero enye zubushake.col-sm
buriwese izahita iba 25% mugari uhereye kumurongo muto no hejuru. Reba auto-layout inkingi igice cyizindi ngero. - Ibyiciro byinkingi byerekana umubare winkingi wifuza gukoresha muri 12 zishoboka kumurongo. Noneho, niba ushaka inkingi eshatu zingana-ubugari hejuru, urashobora gukoresha
.col-4
. - Inkingi
width
s zashyizwe ku ijanisha, nuko zihora zitemba kandi zingana ugereranije nibintu byababyeyi. - Inkingi zifite horizontal
padding
kugirango zireme imiyoboro hagati yinkingi kugiti cye, icyakora, urashobora gukuraho umurongo kumurongomargin
no kumurongopadding
hamwe.no-gutters
na.row
. - Kugirango urusobemiyoboro rusubizwe, hariho ibice bitanu bya gride, imwe kuri buri cyerekezo gisubiza : ibice byose (byoroheje bito), bito, bito, binini, binini cyane.
- Imiyoboro ya gride ishingiye kubugari ntarengwa bwibibazo byitangazamakuru, bivuze ko bikoreshwa kuri iyo ngingo imwe hamwe nibiri hejuru yayo (urugero,
.col-sm-4
ikoreshwa kubito, bito, binini, nibindi bikoresho binini, ariko ntabwo byamberexs
). - Urashobora gukoresha ibyiciro bya grid byateganijwe mbere (nka
.col-4
) cyangwa Sass ivanga kubisobanuro byinshi.
Menya aho ugarukira hamwe nudukosa dukikije flexbox , nkudashobora gukoresha ibintu bimwe na bimwe bya HTML nkibikoresho bya flex .
Mugihe Bootstrap ikoresha em
s cyangwa rem
s mugusobanura ingano nini, px
s zikoreshwa kuri grid break point hamwe nubugari bwa kontineri. Ibi ni ukubera ko ubugari bwa viewport buri muri pigiseli kandi ntabwo ihinduka hamwe nubunini bwimyandikire .
Reba uburyo ibintu bya sisitemu ya Bootstrap ikora mubikoresho byinshi hamwe nameza meza.
Gitoya <576px |
Gitoya ≥576px |
Hagati ≥768px |
Kinini ≥992px |
Kinini kinini ≥1200px |
|
---|---|---|---|---|---|
Ubugari bwa kontineri nini | Nta na kimwe (auto) | 540px | 720px | 960px | 1140px |
Icyiciro cyambere | .col- |
.col-sm- |
.col-md- |
.col-lg- |
.col-xl- |
# yinkingi | 12 | ||||
Ubugari | 30px (15px kuri buri ruhande rw'inkingi) | ||||
Nestable | Yego | ||||
Gutumiza inkingi | Yego |
Koresha ibice-byihariye byinkingi ibyiciro kugirango byoroshye inkingi zingana nta numero igaragara neza nka .col-sm-6
.
Kurugero, hano hari grid grid ebyiri zikoreshwa kuri buri gikoresho no kureba, kuva xs
kuri xl
. Ongeraho umubare uwo ariwo wose wibice-bito byamasomo kuri buri cyiciro ukeneye kandi buri nkingi izaba ubugari bumwe.
Uburinganire buringaniye burashobora gucikamo imirongo myinshi, ariko hariho Safari flexbox ya bugari yabujije gukora gukora idasobanutse flex-basis
cyangwa border
. Hano haribikorwa bya verisiyo ishaje, ariko ntibigomba kuba ngombwa niba ugezweho.
Auto-layout ya flexbox grid inkingi nayo isobanura ko ushobora gushiraho ubugari bwinkingi imwe hanyuma ukagira inkingi ya barumuna ihita ihinduka hafi yayo. Urashobora gukoresha ibyiciro bya grid byateganijwe mbere (nkuko bigaragara hano), imiyoboro ya gride, cyangwa ubugari bwumurongo. Menya ko izindi nkingi zizahindura uko zingana kwagutse.
Koresha col-{breakpoint}-auto
amasomo kugirango ubunini bw'inkingi ukurikije ubugari busanzwe bwibirimo.
Kora ubugari buringaniye bwinkingi zingana imirongo myinshi ushiramo .w-100
aho ushaka ko inkingi zimeneka kumurongo mushya. Kora ibiruhuko byitabirwa no kuvanga .w-100
hamwe nibikorwa bimwe byingirakamaro byerekana .
Imiyoboro ya Bootstrap ikubiyemo ibyiciro bitanu byateganijwe mbere yo kubaka imiterere igoye. Hindura ingano yinkingi zawe hejuru yinyongera ntoya, ntoya, iringaniye, nini, cyangwa ibikoresho binini cyane ariko ubona bikwiye.
Kuri gride nimwe kuva mubikoresho bito kugeza binini, koresha i .col
hamwe .col-*
namasomo. Kugaragaza icyiciro cyumubare mugihe ukeneye inkingi nini cyane; bitabaye ibyo, umva neza .col
.
Ukoresheje icyiciro kimwe .col-sm-*
cyamasomo, urashobora gukora sisitemu shingiro ya grid itangira gutondekanya hanyuma igahinduka itambitse kumwanya muto ( sm
).
Ntushaka ko inkingi zawe zishira gusa murwego runaka? Koresha guhuza ibyiciro bitandukanye kuri buri cyiciro nkuko bikenewe. Reba urugero rukurikira kugirango ubone igitekerezo cyiza cyukuntu byose bikora.
Koresha flexbox ihuza ibikorwa kugirango uhagarike kandi utambitse.
Imyanda iri hagati yinkingi mubyiciro byateganijwe mbere ya grid irashobora gukurwaho hamwe .no-gutters
. Ibi bivanaho ibibi margin
biva kuri .row
na horizontal padding
kuva abana bose bahita.
Hano hari code yinkomoko yo gukora ubu buryo. Menya ko inkingi zirengerwa zashyizwe kumurongo wambere wabana inkingi kandi zigenewe binyuze mubiranga ibiranga . Mugihe ibi bibyara amahitamo yihariye, inkingi ya padi irashobora gukomeza gutegurwa hamwe nibikorwa byingenzi .
Ukeneye igishushanyo mbonera? Kureka ababyeyi .container
cyangwa .container-fluid
.
Mu myitozo, dore uko isa. Icyitonderwa urashobora gukomeza gukoresha ibi hamwe nibindi byose byateganijwe mbere ya gride (harimo ubugari bwinkingi, urwego rwitabira, reorders, nibindi byinshi).
Niba inkingi zirenga 12 zishyizwe mumurongo umwe, buri tsinda ryinyongera zinkingi, nkigice kimwe, zizingira kumurongo mushya.
Kuva 9 + 4 = 13> 12, iyi 4-inkingi-ubugari div irazenguruka kumurongo mushya nkigice kimwe gihuza.
Inkingi zikurikira zirakomeza kumurongo mushya.
Kumena inkingi kumurongo mushya muri flexbox bisaba hack ntoya: ongeramo ikintu hamwe width: 100%
aho ushaka hose kuzinga inkingi kumurongo mushya. Mubisanzwe ibi birangizwa na .row
s nyinshi, ariko ntabwo uburyo bwose bwo kubishyira mubikorwa bushobora kubara ibi.
Urashobora kandi gushira kuruhuka kumwanya wihariye hamwe nibikorwa byacu byerekana neza .
Koresha .order-
amasomo yo kugenzura gahunda igaragara yibirimo. Aya masomo arasubiza, urashobora rero gushiraho kumurongo order
(urugero, .order-1.order-md-2
). Harimo inkunga yo 1
kunyura murwego rwa 12
gride zose uko ari eshanu.
Hariho kandi ibisubizo .order-first
byamasomo .order-last
bihindura ihinduka order
ryikintu ukoresheje order: -1
na order: 13
( order: $columns + 1
), kimwe. Aya masomo arashobora kandi kuvangwa nibyiciro byateganijwe .order-*
nkuko bikenewe.
Urashobora guhagarika grid inkingi muburyo bubiri: .offset-
ibyiciro bya gride byitondewe hamwe nibikorwa byacu bya margin . Urwego rwa gride rufite ubunini bwo guhuza inkingi mugihe marge aringirakamaro cyane muburyo bwihuse aho ubugari bwa offset burahinduka.
Himura inkingi iburyo ukoresheje .offset-md-*
amasomo. Aya masomo yongerera ibumoso bwinkingi *
yinkingi. Kurugero, .offset-md-4
yimuka .col-md-4
hejuru yinkingi enye.
Usibye gusiba inkingi kumurongo wogusubiza, urashobora gukenera gusubiramo offsets. Reba ibi mubikorwa murugero rwa grid .
Hamwe no kwimuka kuri flexbox muri v4, urashobora gukoresha margin yingirakamaro nko .mr-auto
guhatira abavandimwe inkingi kure yundi.
Kugirango ushire ibikubiyemo hamwe na gride isanzwe, ongeramo ibishya .row
kandi ushireho .col-sm-*
inkingi muburyo buriho .col-sm-*
. Imirongo yatoranijwe igomba gushiramo urutonde rwinkingi ziyongera kuri 12 cyangwa nkeya (ntibisabwa ko ukoresha inkingi 12 zose ziboneka).
Iyo ukoresheje inkomoko ya Bootstrap ya Sass dosiye, ufite amahitamo yo gukoresha Sass variable hamwe na mixin kugirango ukore imiterere, ibisobanuro, nibisubizo byurupapuro. Ibyiciro byateganijwe mbere ya gride ikoresha ibyo bihinduka hamwe na mixin kugirango itange suite yose yiteguye-gukoresha-amasomo yo kwihutisha imiterere.
Ibihinduka n'amakarita bigena umubare winkingi, ubugari bwamazi, hamwe nibibazo byitangazamakuru aho byatangirira kureremba inkingi. Twifashishije kugirango tubyare ibyiciro byateganijwe byateganijwe hejuru, kimwe no kuvanga ibicuruzwa byavuzwe haruguru.
Imvange zikoreshwa zifatanije na gride ihindagurika kugirango itange ibisobanuro bya CSS kumasoko ya grid inkingi.
Urashobora guhindura ibihinduka kubiciro byawe bwite, cyangwa ugakoresha gusa ivanga nagaciro kabo gasanzwe. Dore urugero rwo gukoresha igenamiterere risanzwe kugirango ukore imiterere-inkingi ebyiri hamwe nu cyuho hagati.
Ukoresheje ibyubatswe muri gride Sass ihinduka namakarita, birashoboka guhitamo byimazeyo ibyiciro byateganijwe mbere. Hindura umubare wibyiciro, ibipimo byibibazo byitangazamakuru, nubugari bwa kontineri - hanyuma usubiremo.
Umubare wa grid inkingi urashobora guhinduka ukoresheje Sass variable. $grid-columns
ni Byakoreshejwe Kuri Kubyara Ubugari (ku ijana) ya buri nkingi ku giti cye mugihe $grid-gutter-width
ishyiraho ubugari bwinkingi.
Kwimuka kurenga inkingi ubwazo, urashobora kandi guhitamo umubare wa grid tiers. Niba ushaka ibice bine bya gride, wavugurura $grid-breakpoints
kandi $container-max-widths
kubintu nkibi:
Mugihe uhinduye ibintu byose bihinduka cyangwa ikarita ya Sass, uzakenera kubika impinduka zawe no kwisubiraho. Kubikora bizasohoka ibishya bishya byateganijwe mbere ya gride ibyiciro kubugari bwinkingi, offsets, no gutumiza. Ibisubizo byingirakamaro byingirakamaro nabyo bizavugururwa kugirango ukoreshe ibicuruzwa byacitse. Witondere gushiraho indangagaciro muri px
(ntabwo rem
, em
cyangwa, %
).