Bootstrap imamangidwa pa gridi yomvera yamagulu 12. Taphatikizanso masanjidwe okhazikika komanso amadzimadzi-width motengera dongosololi.
Bootstrap imagwiritsa ntchito zinthu za HTML ndi CSS zomwe zimafuna kugwiritsa ntchito HTML5 doctype. Onetsetsani kuti mwayiphatikiza kumayambiriro kwa tsamba lililonse la Bootstrapped mu polojekiti yanu.
- <!DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
Mkati mwa fayilo ya scaffolding.less , timayika mawonedwe ofunikira padziko lonse lapansi, kalembedwe, ndi masitaelo a maulalo. Makamaka, ife:
background-color: white;
pabody
@baseFontFamily
, @baseFontSize
, ndi mawonekedwe @baseLineHeight
ngati maziko athu a kalembedwe@linkColor
ndikugwiritsa ntchito mizere ya ulalo pokha:hover
Pofika pa Bootstrap 2, kukonzanso kwachikhalidwe kwa CSS kwasintha kugwiritsa ntchito zinthu zochokera ku Normalize.css , pulojekiti ya Nicolas Gallagher yomwe imapatsanso mphamvu HTML5 Boilerplate .
Kukonzanso kwatsopano kumatha kupezekabe mu reset.less , koma ndi zinthu zambiri zomwe zachotsedwa chifukwa chakufupikitsa komanso kulondola.
Makina osasinthika a gridi omwe amaperekedwa ku Bootstrap amagwiritsa ntchito mizati 12 yomwe imapereka m'lifupi mwake 724px, 940px (zosasinthika popanda CSS yomvera ikuphatikizidwa), ndi 1170px. Pansi pa mawonedwe a 767px, mizatiyo imakhala yamadzimadzi ndipo imasunthidwa molunjika.
- <div class = "mzere" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Monga tawonera apa, masanjidwe oyambira atha kupangidwa ndi "mizere" iwiri, iliyonse imakhala ndi magawo 12 oyambira omwe tafotokoza kuti ndi gawo la gridi yathu.
- <div class = "mzere" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset4" > ... </div>
- </div>
Ndi static (non-fluid) grid system ku Bootstrap, kumanga zisa ndikosavuta. Kuti muwononge zomwe muli nazo, ingowonjezerani zatsopano .row
ndi magulu omwe ali .span*
muzambiri zomwe zilipo kale .span*
.
Mizere yoyikidwa mu zisa iyenera kukhala ndi zigawo zomwe zimawonjezera kuchuluka kwa mizere ya kholo lawo. Mwachitsanzo, .span3
mizati iwiri yokhala ndi zisa iyenera kuyikidwa mkati mwa .span6
.
- <div class = "mzere" >
- <div class = "span6" >
- Gawo 1 gawo
- <div class = "mzere" >
- <div class = "span3" > Level 2 </div>
- <div class = "span3" > Level 2 </div>
- </div>
- </div>
- </div>
Dongosolo la gridi yamadzimadzi limagwiritsa ntchito maperesenti pamagawo apakati m'malo mwa ma pixel okhazikika. Ilinso ndi kusinthika kofanana ndi kachitidwe kathu ka gridi yokhazikika, kuwonetsetsa kuchuluka koyenera pazosankha zazikulu zazithunzi ndi zida.
Pangani mzere uliwonse wamadzimadzi posintha .row
kukhala .row-fluid
. Mipingo imakhala yofanana ndendende, zomwe zimapangitsa kuti zikhale zowongoka kwambiri kuti zisinthe pakati pa masanjidwe okhazikika ndi amadzimadzi.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Kuyika zisa ndi ma gridi amadzimadzi ndikosiyana pang'ono: kuchuluka kwa zisa zomwe zili ndi zisa sizifunikira kufanana ndi kholo. M'malo mwake, magawo anu amakonzedwanso pamlingo uliwonse chifukwa mzere uliwonse umatenga 100% ya gawo la makolo.
- <div class = "row-fluid" >
- <div class = "span12" >
- Gawo 1 la gawo
- <div class = "row-fluid" >
- <div class = "span6" > Level 2 </div>
- <div class = "span6" > Level 2 </div>
- </div>
- </div>
- </div>
Zosintha | Mtengo wofikira | Kufotokozera |
---|---|---|
@gridColumns |
12 | Chiwerengero cha mizati |
@gridColumnWidth |
60px pa | Kukula kwa ndime iliyonse |
@gridGutterWidth |
20px pa | Malo opanda pake pakati pa mizati |
Omangidwa mu Bootstrap ndi mitundu ingapo yosinthira makonda a 940px grid system, zolembedwa pamwambapa. Zosintha zonse za gridi zimasungidwa mu variables.less.
Kusintha gululi kumatanthauza kusintha zosintha zitatu @grid*
ndikubwezeretsanso Bootstrap. Sinthani zosintha za gululi mu zosintha.less ndikugwiritsa ntchito imodzi mwa njira zinayi zolembedwa kuti muwonjezere . Ngati mukuwonjezera mizati yambiri, onetsetsani kuti mwawonjezera CSS kwa omwe ali mu grid.less.
Kusintha kwa gridi kumangogwira ntchito mosakhazikika, gridi ya 940px. Kuti mukhalebe ndi mawonekedwe a Bootstrap, muyeneranso kusintha ma grids mu responsive.less.
Zosasintha komanso zosavuta 940px-wide, masanjidwe apakati pafupifupi patsamba lililonse kapena tsamba loperekedwa ndi <div class="container">
.
- <thupi>
- <div class = "chotengera" >
- ...
- </div>
- </ thupi>
<div class="container-fluid">
imapereka mawonekedwe osinthika amasamba, min- ndi max-widths, ndi chotchinga chakumanzere. Ndi yabwino kwa mapulogalamu ndi zolemba.
- <div class = "container-fluid" >
- <div class = "row-fluid" >
- <div class = "span2" >
- <!--Zam'mbali mwa mbali-->
- </div>
- <div class = "span10" >
- <!--Zokhudza thupi-->
- </div>
- </div>
- </div>
Mafunso azama media amalola CSS yokhazikika kutengera momwe zinthu ziliri, kuchuluka, kutalika, mtundu wowonetsera, ndi zina zambiri, koma nthawi zambiri zimayang'ana mozungulira min-width
ndi max-width
.
Gwiritsani ntchito mafunso atolankhani moyenera komanso ngati poyambira kwa omvera anu am'manja. Pama projekiti akuluakulu, lingalirani zoyambira zodzipatulira osati zigawo za mafunso azama TV.
Bootstrap imathandizira mafunso angapo atolankhani mufayilo imodzi kuti ikuthandizeni kupanga mapulojekiti anu kukhala oyenera pazida zosiyanasiyana komanso zowonera. Nazi zomwe zikuphatikizidwa:
Label | Kamangidwe m'lifupi | M'lifupi mwake | Kuchuluka kwa ngalande |
---|---|---|---|
Mafoni am'manja | 480px ndi pansipa | Zigawo zamadzimadzi, palibe makulidwe okhazikika | |
Ma Smartphones ku mapiritsi | 767px ndi pansipa | Zigawo zamadzimadzi, palibe makulidwe okhazikika | |
Mapiritsi a zithunzi | 768px ndi pamwamba | 42px pa | 20px pa |
Zosasintha | 980px ndi mmwamba | 60px pa | 20px pa |
Chiwonetsero chachikulu | 1200px ndi mmwamba | 70px pa | 30px pa |
Kuti muwonetsetse kuti zida zikuwonetsa masamba omvera bwino, phatikizani tag yowonera.
- <meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
Bootstrap sichimangophatikiza mafunso awa, koma kumvetsetsa ndikuwonjezera ndikosavuta ndipo kumafuna kukhazikitsidwa kochepa. Muli ndi zosankha zingapo zophatikizira zomvera za Bootstrap:
Bwanji osangophatikizamo? Kunena zoona, sikuti zonse zimafunika kulabadira. M'malo molimbikitsa okonza mapulogalamu kuti achotse izi, timawona kuti ndibwino kuti tithe.
- /* Mafoni amtundu ndi pansi */
- @media ( max - wide : 480px ) { ... }
- /* Mawonekedwe a foni kuti azijambula piritsi */
- @media ( max - wide : 767px ) { ... }
- /* Chithunzi piritsi ku malo ndi desktop */
- @media ( min - wide : 768px ) ndi ( max - wide : 979px ) { ... }
- /* Desktop yayikulu */
- @media ( min - wide : 1200px ) { ... }
Kuti mukhale ofulumira kugwiritsa ntchito mafoni, gwiritsani ntchito makalasi ofunikirawa kuti muwonetse ndi kubisa zomwe zili pazida.
Gwiritsani ntchito pang'ono ndikupewa kupanga mitundu yosiyana ya tsamba lomwelo. M'malo mwake, zigwiritseni ntchito kuti zigwirizane ndi mawonekedwe a chipangizo chilichonse.
Mwachitsanzo, mutha kuwonetsa <select>
chinthu cha nav pamapangidwe am'manja, koma osati pamapiritsi kapena pakompyuta.
Chowonetsedwa apa ndi tebulo la makalasi omwe timathandizira ndi momwe amakhudzira pamafunso amtundu wina (olembedwa ndi chipangizo). Amapezeka mu responsive.less
.
Kalasi | Mafoni480px ndi pansipa | Mapiritsi767px ndi pansipa | Makompyuta apakompyuta768px ndi pamwamba |
---|---|---|---|
.visible-phone |
Zowoneka | Zobisika | Zobisika |
.visible-tablet |
Zobisika | Zowoneka | Zobisika |
.visible-desktop |
Zobisika | Zobisika | Zowoneka |
.hidden-phone |
Zobisika | Zowoneka | Zowoneka |
.hidden-tablet |
Zowoneka | Zobisika | Zowoneka |
.hidden-desktop |
Zowoneka | Zowoneka | Zobisika |
Sinthani kukula kwa msakatuli wanu kapena tsegulani pazida zosiyanasiyana kuti muyese makalasi omwe ali pamwambapa.
Zizindikiro zobiriwira zikuwonetsa kuti kalasi ikuwoneka pamalo omwe mumawonera.
Apa, zolembera zobiriwira zikuwonetsa kuti kalasi yabisika pamalo omwe mukuwona.