Bootstrap imamangidwa pama gridi amitundu 12, masanjidwe, ndi zida.
Bootstrap imagwiritsa ntchito zinthu zina za HTML ndi CSS zomwe zimafuna kugwiritsa ntchito HTML5 doctype. Phatikizanipo kumayambiriro kwa ntchito zanu zonse.
- <!DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
Bootstrap imayika mawonedwe oyambira padziko lonse lapansi, typography, ndi masitayilo a ulalo. Makamaka, ife:
margin
pa thupibackground-color: white;
pabody
@baseFontFamily
, @baseFontSize
, ndi mawonekedwe @baseLineHeight
monga typographic maziko athu@linkColor
ndikugwiritsa ntchito mizere ya ulalo pokha:hover
Masitayilo awa atha kupezeka mkati mwa scaffolding.less .
Ndi Bootstrap 2, chipika chakale chokhazikitsanso chatsitsidwa mokomera Normalize.css , pulojekiti ya Nicolas Gallagher ndi Jonathan Neal yomwe imapatsanso mphamvu HTML5 Boilerplate . Ngakhale timagwiritsa ntchito zambiri za Normalize mkati mwa reset.less , tachotsa zinthu zina za Bootstrap.
Makina osasinthika a gridi ya Bootstrap amagwiritsa ntchito mizati 12 , kupanga chidebe chachikulu cha 940px popanda kuyankha . Ndi fayilo yomvera ya CSS yowonjezeredwa, gululiyo imasintha kukhala 724px ndi 1170px m'lifupi kutengera malo anu owonera. Pansi pa mawonedwe a 767px, mizatiyo imakhala yamadzimadzi ndipo imasunthidwa molunjika.
Kuti mupange magawo awiri osavuta, pangani a .row
ndikuwonjezera nambala yoyenera .span*
yamizere. Popeza iyi ndi gridi ya mizere 12, iliyonse .span*
imatambasula zingapo mwa magawo 12, ndipo nthawi zonse imayenera kuwonjezera mpaka 12 pamzere uliwonse (kapena kuchuluka kwa magawo a kholo).
- <div class = "mzere" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Potengera chitsanzo ichi, tili .span4
ndi .span8
, kupanga mizati 12 ndi mzere wathunthu.
Sunthani mizati kumanja pogwiritsa ntchito .offset*
makalasi. Kalasi iliyonse imawonjezera malire akumanzere kwa ndime ndi gawo lonse. Mwachitsanzo, .offset4
amasuntha .span4
mizati inayi.
- <div class = "mzere" >
- <div class = "span4" > ... </div>
- <div class = "span3 offset2" > ... </div>
- </div>
Kuti mutsegule zomwe zili ndi gridi yokhazikika, onjezani magawo atsopano .row
ndi magulu omwe ali .span*
mgulu lomwe lilipo .span*
. Mizere yoyikidwa mu zisa iyenera kukhala ndi zigawo zomwe zimawonjezera kuchuluka kwa mizere ya kholo lawo.
- <div class = "mzere" >
- <div class = "span9" >
- Gawo 1 gawo
- <div class = "mzere" >
- <div class = "span6" > Level 2 </div>
- <div class = "span3" > Level 2 </div>
- </div>
- </div>
- </div>
Dongosolo la gridi yamadzimadzi limagwiritsa ntchito maperesenti m'malo mwa ma pixels pazambiri. Ili ndi mphamvu zoyankhira zomwezo monga dongosolo lathu lokhazikika la gridi, kuwonetsetsa kuchuluka koyenera pazosankha zazikulu zazithunzi ndi zida.
Pangani mzere uliwonse "madzimadzi" posintha .row
kukhala .row-fluid
. Makalasi a magawo amakhala chimodzimodzi, zomwe zimapangitsa kuti zikhale zosavuta kusuntha pakati pa gridi yokhazikika ndi yamadzimadzi.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Imagwira ntchito mofanana ndi ndondomeko yokhazikika ya grid system: onjezani pamndandanda .offset*
uliwonse kuti muthetse ndi mizere yambiri.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset2" > ... </div>
- </div>
Ma gridi amadzimadzi amagwiritsa ntchito zisa mosiyanasiyana: mulingo uliwonse wa zisa uyenera kuwonjezera mpaka mizati 12. Izi ndichifukwa choti gululi lamadzimadzi limagwiritsa ntchito maperesenti, osati ma pixel, pokhazikitsa m'lifupi.
- <div class = "row-fluid" >
- <div class = "span12" >
- Madzi 12
- <div class = "row-fluid" >
- <div class = "span6" >
- Madzi 6
- <div class = "row-fluid" >
- <div class = "span6" > Fluid 6 </div>
- <div class = "span6" > Fluid 6 </div>
- </div>
- </div>
- <div class = "span6" > Fluid 6 </div>
- </div>
- </div>
- </div>
Amapereka mawonekedwe amtundu wokhazikika (ndipo omvera) omwe <div class="container">
amafunikira okha.
- <thupi>
- <div class = "chotengera" >
- ...
- </div>
- </ thupi>
Pangani tsamba lamadzi, la magawo awiri ndi <div class="container-fluid">
-labwino pamapulogalamu 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>
Yatsani CSS yomvera mu projekiti yanu pophatikiza meta tag yoyenera ndi masitayelo owonjezera mkati <head>
mwa chikalata chanu. Ngati mwapanga Bootstrap kuchokera patsamba la Sinthani Mwamakonda Anu, muyenera kungophatikiza meta tag.
- <meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
- <link href = "assets/css/bootstrap-responsive.css" rel = "stylesheet" >
Mungodziwiratu!Bootstrap sichimaphatikizapo zomvera mwachisawawa panthawiyi chifukwa sizinthu zonse zomwe zimayenera kuyankha. M'malo molimbikitsa omanga kuti achotse izi, timawona kuti ndibwino kuti tithandizire momwe zingafunikire.
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 magawo a 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 |
---|---|---|---|
Chiwonetsero chachikulu | 1200px ndi mmwamba | 70px pa | 30px pa |
Zosasintha | 980px ndi mmwamba | 60px pa | 20px pa |
Mapiritsi a zithunzi | 768px ndi pamwamba | 42px pa | 20px pa |
Mafoni ku mapiritsi | 767px ndi pansipa | Zigawo zamadzimadzi, palibe makulidwe okhazikika | |
Mafoni | 480px ndi pansipa | Zigawo zamadzimadzi, palibe makulidwe okhazikika |
- /* Desktop yayikulu */
- @media ( min - wide : 1200px ) { ... }
- /* Chithunzi piritsi ku malo ndi desktop */
- @media ( min - wide : 768px ) ndi ( max - wide : 979px ) { ... }
- /* Mawonekedwe a foni kuti azijambula piritsi */
- @media ( max - wide : 767px ) { ... }
- /* Mafoni amtundu ndi pansi */
- @media ( max - wide : 480px ) { ... }
Kuti mupange chitukuko chosavuta kugwiritsa ntchito mafoni, gwiritsani ntchito makalasi othandizirawa kuti muwonetse ndikubisa zomwe zili pazida. M'munsimu muli tebulo la makalasi omwe alipo ndi zotsatira zake pamafunso amtundu woperekedwa (olembedwa ndi chipangizo). Amapezeka mu responsive.less
.
Kalasi | Mafoni767px ndi pansipa | Mapiritsi979px mpaka 768px | Makompyuta apakompyutaZosasintha |
---|---|---|---|
.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 |
Gwiritsani ntchito pang'ono ndikupewa kupanga mitundu yosiyana ya tsamba lomwelo. M'malo mwake, zigwiritseni ntchito kuti zigwirizane ndi mawonekedwe a chipangizo chilichonse. Zida zoyankhira siziyenera kugwiritsidwa ntchito ndi matebulo, ndipo motero sizimathandizidwa.
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.