Hoʻokumu ʻia ʻo Bootstrap ma kahi mākia 12-kolume pane. Ua hoʻokomo pū mākou i nā hoʻolālā paʻa a me ka laula wai e pili ana i kēlā ʻōnaehana.
Hoʻohana ʻo Bootstrap i nā mea HTML a me nā waiwai CSS e koi ai i ka hoʻohana ʻana i ka HTML5 doctype. E hōʻoia e hoʻokomo iā ia ma ka hoʻomaka o kēlā me kēia ʻaoʻao Bootstrapped i kāu papahana.
- <!DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
I loko o ka waihona scaffolding.less , hoʻonoho mākou i nā ʻano hōʻike honua kumu, typography, a me nā ʻano loulou. ʻOiaʻiʻo, mākou:
background-color: white;
ma kabody
@baseFontFamily
, @baseFontSize
, a me @baseLineHeight
nā hiʻohiʻona e like me kā mākou kumu kikokikona@linkColor
a hoʻopili i nā kaha lalo ma ka loulou:hover
E like me Bootstrap 2, ua ulu ka hoʻoponopono CSS kuʻuna e hoʻohana i nā mea mai Normalize.css , kahi papahana na Nicolas Gallagher e mana pū ana i ka HTML5 Boilerplate .
Hiki ke loaʻa ka hoʻoponopono hou ma reset.less , akā me nā mea he nui i wehe ʻia no ka pōkole a me ka pololei.
Hoʻohana ka ʻōnaehana mākia paʻamau i hāʻawi ʻia ma Bootstrap i nā kolamu 12 e hāʻawi ana i ka laulā o 724px, 940px (paʻamau me ka CSS pane ʻole), a me 1170px. Ma lalo o 767px viewports, lilo nā kolamu i ka wai a hoʻopaʻa pololei.
- <div class="laina"> papa = "lālani" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
E like me ka mea i hōʻike ʻia ma ʻaneʻi, hiki ke hana ʻia kahi hoʻolālā kumu me ʻelua "koluma", kēlā me kēia me ka helu o nā kolamu kumu 12 a mākou i wehewehe ai ma ke ʻano he ʻāpana o kā mākou pūnaewele puni honua.
- <div class="laina"> papa = "lālani" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset4" > ... </div>
- </div>
Me ka ʻōnaehana static (non-fluid) ma Bootstrap, maʻalahi ka nesting. No ka hoʻopaʻa ʻana i kāu ʻike, hoʻohui wale i kahi kolamu hou .row
a hoʻonohonoho i .span*
loko o kahi .span*
kolamu e kū nei.
Pono nā lālani i hoʻopaʻa ʻia he pūʻulu kolamu e hoʻohui i ka helu o nā kolamu o kona makua. No ka laʻana, .span3
pono e kau ʻia nā kolamu ʻelua i loko o kahi .span6
.
- <div class="laina"> papa = "lālani" >
- <div class = "span6" >
- pae 1 kolamu
- <div class = "lālani" >
- <div class = "span3" > Papa 2 </div>
- <div class = "span3" > Papa 2 </div>
- </div>
- </div>
- </div>
Hoʻohana ka ʻōnaehana mānoanoa wai i nā pākēneka no ka laulā kolamu ma kahi o nā pika paʻa. Loaʻa iā ia nā ʻano like ʻole e like me kā mākou ʻōnaehana grid paʻa, e hōʻoia ana i nā ʻāpana kūpono no nā ʻōkuhi pale kī a me nā mea hana.
Hana i kekahi lālani wai ma ka hoʻololi wale .row
ʻana i .row-fluid
. Noho like nā kolamu, e maʻalahi loa ka hoʻololi ʻana ma waena o nā hoʻonohonoho paʻa a me ka wai.
- <div class="row-fluid"> papa = "laina-wai" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
He ʻokoʻa iki ka hoʻomoe ʻana me nā puna wai: ʻaʻole pono ka helu o nā kolamu pūnana i ka makua. Akā, hoʻonohonoho hou ʻia kāu mau kolamu ma kēlā me kēia pae no ka mea e lawe ana kēlā me kēia lālani i ka 100% o ke kolamu makua.
- <div class="row-fluid"> papa = "laina-wai" >
- <div class = "span12" >
- Papa 1 o ke kolamu
- <div class = "laina-wai" >
- <div class = "span6" > Papa 2 </div>
- <div class = "span6" > Papa 2 </div>
- </div>
- </div>
- </div>
Hoʻololi | Waiwai paʻamau | wehewehe |
---|---|---|
@gridColumns |
12 | Ka helu o nā kolamu |
@gridColumnWidth |
60px | Laulā o kēlā me kēia kolamu |
@gridGutterWidth |
20px | Kaawale ʻino ma waena o nā kolamu |
Hoʻokomo ʻia i loko o Bootstrap he mau ʻāpana liʻiliʻi no ka hoʻoponopono ʻana i ka ʻōnaehana grid 940px paʻamau, i kākau ʻia ma luna. Mālama ʻia nā mea hoʻololi a pau no ka mānoanoa ma nā variables.less.
ʻO ka hoʻololi ʻana i ka mānoanoa ʻo ia ka hoʻololi ʻana i nā ʻano ʻekolu @grid*
a me ka hoʻopili hou ʻana iā Bootstrap. E hoʻololi i nā mea hoʻololi pūnaewele ma variables.less a hoʻohana i kekahi o nā ala ʻehā i palapala ʻia no ka hoʻopili hou ʻana . Inā hoʻohui ʻoe i nā kolamu hou aʻe, e ʻoluʻolu e hoʻohui i ka CSS no ka poʻe ma grid.less.
ʻO ka hana maʻamau o ka mākia wale nō e hana ma ka pae paʻamau, ka mākia 940px. No ka mālama ʻana i nā ʻano pane o Bootstrap, pono ʻoe e hoʻopilikino i nā grids ma responsive.less.
ʻO ka paʻamau a me ka maʻalahi 940px-ākea, hoʻolālā kikowaena no kahi pūnaewele a i ʻole ʻaoʻao i hāʻawi ʻia e hoʻokahi <div class="container">
.
- <kino>
- <div class = "container" >
- ...
- </div>
- </kino>
<div class="container-fluid">
hāʻawi i ka hoʻolālā ʻaoʻao maʻalahi, min- a me max-ākea, a me kahi ʻaoʻao ʻaoʻao hema. He mea maikaʻi no nā polokalamu a me nā palapala.
- <div class="container-fluid"> papa = "container-fluid" >
- <div class = "laina-wai" >
- <div class = "span2" >
- <!--Maʻiʻo ʻaoʻao-->
- </div>
- <div class = "span10" >
- <!--Maʻiʻo kino-->
- </div>
- </div>
- </div>
Hiki i nā nīnau Media ke loaʻa CSS maʻamau e pili ana i nā kūlana he nui-nā ratios, ākea, ʻano hōʻikeʻike, a me nā mea ʻē aʻe—akā e nānā maʻamau a puni min-width
a max-width
.
E hoʻohana i nā nīnau media me ke kuleana a ma ke ʻano he hoʻomaka wale nō i kāu poʻe hoʻolohe kelepona. No nā papahana nui aʻe, e noʻonoʻo i nā waihona code i hoʻolaʻa ʻia a ʻaʻole nā papa o nā nīnau media.
Kākoʻo ʻo Bootstrap i kahi liʻiliʻi o nā nīnau media i hoʻokahi faila e kōkua i ka hoʻolilo ʻana i kāu mau papahana i kūpono i nā mea like ʻole a me nā hoʻonā pale. Eia ka mea i komo:
Lepili | Laulā hoʻolālā | laulā kolamu | Laulā ʻauwai |
---|---|---|---|
Smartphones | 480px a lalo | Nā kolamu wai, ʻaʻohe laula paʻa | |
Nā kelepona i nā papa | 767px a lalo | Nā kolamu wai, ʻaʻohe laula paʻa | |
Nā papa kiʻi | 768px a i luna | 42px | 20px |
Default | 980px a i luna | 60px | 20px |
Hōʻike nui | 1200px a piʻi | 70px | 30px |
No ka hōʻoia pono ʻana i nā ʻaoʻao pane pololei, e hoʻokomo i ka tag meta viewport.
- <meta name="viewport" content="width=device-width, initial-scale=1.0"> inoa = "viewport" maʻiʻo = "ākea=ākea-ākea, initial-scale=1.0" >
ʻAʻole hoʻokomo ʻokoʻa ʻo Bootstrap i kēia mau nīnau media, akā maʻalahi loa ka hoʻomaopopo ʻana a me ka hoʻohui ʻana iā lākou a pono ka hoʻonohonoho liʻiliʻi. Loaʻa iā ʻoe kekahi mau koho no ka hoʻopili ʻana i nā hiʻohiʻona pane o Bootstrap:
No ke aha e hoʻokomo ʻole ai? ʻO ka ʻoiaʻiʻo, ʻaʻole pono nā mea a pau e pane. Ma kahi o ka paipai ʻana i nā mea hoʻomohala e wehe i kēia hiʻohiʻona, manaʻo mākou he mea maikaʻi loa ia e hiki ai.
- /* Nā kelepona ʻāina a i lalo *//* Nā kelepona ʻāina a i lalo */
- @media ( max - laula : 480px ) { ... }
- /* Kelepona ʻāina i ka papa kiʻi kiʻi */
- @media ( ka nui - laula : 767px ) { ... }
- /* Kiʻi papa i ka ʻāina a me ka pākaukau */
- @media ( min - laula : 768px ) a me ( max - laula : 979px ) { ... }
- /* Papakaukau nui */
- @media ( min - laula : 1200px ) { ... }
No ka hoʻomohala wikiwiki ʻana i ka paʻa lima, e hoʻohana i kēia mau papa pono no ka hōʻike ʻana a me ka hūnā ʻana i nā ʻike e ka hāmeʻa.
E hoʻohana ma ka palena palena a pale i ka hana ʻana i nā mana like ʻole o ka pūnaewele hoʻokahi. Akā, e hoʻohana iā lākou e hoʻokō i ka hōʻike ʻana o kēlā me kēia hāmeʻa.
No ka laʻana, hiki iā ʻoe ke hōʻike i kahi <select>
mea no ka nav ma nā hoʻolālā paʻa lima, akā ʻaʻole ma nā papa a i ʻole nā papakaukau.
Hōʻike ʻia ma ʻaneʻi kahi papa o nā papa a mākou e kākoʻo ai a me kā lākou hopena ma kahi hoʻonohonoho nīnau nīnau media i hāʻawi ʻia (i hōʻailona ʻia e ka mea hana). Hiki ke loaʻa iā lākou ma responsive.less
.
Papa | Kelepona480px a lalo | Papa papa767px a lalo | Papahana768px a i luna |
---|---|---|---|
.visible-phone |
ʻIke ʻia | Huna | Huna |
.visible-tablet |
Huna | ʻIke ʻia | Huna |
.visible-desktop |
Huna | Huna | ʻIke ʻia |
.hidden-phone |
Huna | ʻIke ʻia | ʻIke ʻia |
.hidden-tablet |
ʻIke ʻia | Huna | ʻIke ʻia |
.hidden-desktop |
ʻIke ʻia | ʻIke ʻia | Huna |
E hoʻololi i kāu polokalamu kele pūnaewele a hoʻouka paha i nā mea like ʻole e hoʻāʻo i nā papa ma luna.
Hōʻike ʻia nā kaha ʻōmaʻomaʻo e ʻike ʻia ka papa ma kāu awa nānā i kēia manawa.
Maʻaneʻi, hōʻike ʻia nā kaha ʻōmaʻomaʻo e hūnā ʻia ka papa i kāu ʻike ʻike i kēia manawa.