I-Bootstrap yakhelwe kugridi yamakholomu angu-12 ephendulayo. Siphinde safaka nezakhiwo ezingaguquki- kanye nobubanzi be-fluid-width ngokusekelwe kuleyo sistimu.
I-Bootstrap isebenzisa izakhi ze-HTML kanye nezakhiwo ze-CSS ezidinga ukusetshenziswa kwe-HTML5 doctype. Qiniseka ukuthi uyayifaka ekuqaleni kwawo wonke amakhasi ane-Bootstrapped kuphrojekthi yakho.
- <!DOCTYPE html>
- <html lang = "zu" >
- ...
- </html>
Ngaphakathi kwefayela le- scaffolding.less , sibeka isibonisi somhlaba esiyisisekelo, i-typography, nezitayela zokuxhumanisa. Ngokukhethekile, thina:
background-color: white;
kubody
@baseFontFamily
, @baseFontSize
, kanye @baseLineHeight
nezibaluli njengesisekelo sethu se-typography@linkColor
futhi usebenzise isixhumanisi esidwebelayo kuphela:hover
Kusukela nge-Bootstrap 2, ukusetha kabusha kwe-CSS okungokwesiko kuthuthukile ukuze kusetshenziswe izici ezisuka ku- Normalize.css , iphrojekthi ka- Nicolas Gallagher ephinde enike amandla i- HTML5 Boilerplate .
Ukusetha kabusha okusha kusengatholakala kokuthi reset.less , kodwa kunezici eziningi ezikhishiwe ukuze kube mfushane nokunemba.
Isistimu yegridi ezenzakalelayo enikezwe ku-Bootstrap isebenzisa amakholomu angu-12 anikezela ngobubanzi obungu-724px, 940px (okuzenzakalelayo ngaphandle kwe-CSS ephendulayo efakiwe), kanye no-1170px. Ngaphansi kwezimbobo zokubuka ezingu-767px, amakholomu aba uketshezi futhi anqwabelene ngokuqondile.
- <div class = "row" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Njengoba kuboniswe lapha, ukwakheka okuyisisekelo kungadalwa “namakholomu” amabili, ngalinye lihlanganisa inani lamakholomu ayisisekelo angu-12 esiwachaze njengengxenye yesistimu yethu yegridi.
- <div class = "row" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset4" > ... </div>
- </div>
Ngesistimu yegridi emile (engenamanzi) ku-Bootstrap, ukwenza isidleke kulula. Ukuze uhlanganise okuqukethwe kwakho, vele wengeze okusha .row
nesethi .span*
yamakholomu ngaphakathi kwekholomu ekhona .span*
.
Imigqa efakwe kusidleke kufanele ifake isethi yamakholomu ahlanganisa inani lamakholomu omzali wayo. Isibonelo, .span3
amakholomu amabili anesidleke kufanele abekwe ngaphakathi kwe- .span6
.
- <div class = "row" >
- <div class = "span6" >
- Ikholomu yeleveli 1
- <div class = "row" >
- <div class = "span3" > Izinga 2 </div>
- <div class = "span3" > Izinga 2 </div>
- </div>
- </div>
- </div>
Isistimu yegridi ewuketshezi isebenzisa amaphesenti obubanzi bekholomu esikhundleni samaphikseli angashintshi. Iphinde ibe nokuhlukahluka okusabelayo okufanayo njengesistimu yethu yegridi engashintshi, iqinisekisa izilinganiso ezifanele zesinqumo esibalulekile sesikrini namadivayisi.
Yenza noma yimuphi umugqa ube uketshezi ngokushintsha .row
ube ngu- .row-fluid
. Amakholomu ahlala efana ncamashi, okwenza kube lula kakhulu ukupheqa phakathi kwezakhiwo ezingaguquki neziwuketshezi.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Ukwenza isidleke ngamagridi awuketshezi kuhluke kancane: inani lamakholomu afakwe isidleke alidingi ukufana nomzali. Kunalokho, amakholomu akho asethwa kabusha kuleveli ngayinye ngenxa yokuthi umugqa ngamunye uthatha u-100% wekholomu yomzali.
- <div class = "row-fluid" >
- <div class = "span12" >
- Ileveli 1 yekholomu
- <div class = "row-fluid" >
- <div class = "span6" > Izinga 2 </div>
- <div class = "span6" > Izinga 2 </div>
- </div>
- </div>
- </div>
Iyaguquguquka | Inani elizenzakalelayo | Incazelo |
---|---|---|
@gridColumns |
12 | Inombolo yamakholomu |
@gridColumnWidth |
60px | Ububanzi bekholomu ngayinye |
@gridGutterWidth |
20px | Isikhala esingesihle phakathi kwamakholomu |
Okwakhelwe ku-Bootstrap yidlanzana lezinto eziguquguqukayo zokwenza ngokwezifiso isistimu yegridi engu-940px, ebhalwe ngenhla. Zonke eziguquguqukayo zegridi zigcinwa kuma-variables.less.
Ukushintsha igridi kusho ukushintsha @grid*
okuguquguqukayo okuthathu nokubuyisela kabusha i-Bootstrap. Shintsha okuguquguqukayo kwegridi kokuguquguqukayo.kancane futhi usebenzise enye yezindlela ezine ezibhalwe phansi ukuze uhlanganise . Uma wengeza amakholomu engeziwe, qiniseka ukuthi ungeza i-CSS yalawo aku-grid.less.
Ukwenza ngendlela oyifisayo igridi kusebenza kuphela ezingeni elimisiwe, igridi engu-940px. Ukuze ulondoloze izici ezisabelayo ze-Bootstrap, kuzodingeka futhi wenze ngendlela oyifisayo amagridi ngokusabela.less.
Isakhiwo esimisiwe nesilula esibanzi esingu-940px-wide, esimaphakathi sanoma iyiphi iwebhusayithi noma ikhasi elihlinzekwe ngomunye <div class="container">
.
- <umzimba>
- <div class = "container" >
- ...
- </div>
- </umzimba>
<div class="container-fluid">
inikeza ukwakheka kwekhasi okuguquguqukayo, ububanzi obuncane kanye nobukhulu obukhulu, kanye nebha eseceleni engakwesobunxele. Ilungele izinhlelo zokusebenza namadokhumenti.
- <div class = "container-fluid" >
- <div class = "row-fluid" >
- <div class = "span2" >
- <!--Okuqukethwe kwebha eseceleni-->
- </div>
- <div class = "span10" >
- <!--Okuqukethwe komzimba-->
- </div>
- </div>
- </div>
Imibuzo yemidiya ivumela i-CSS yangokwezifiso ngokususelwe kwinani lemibandela—izilinganiso, ububanzi, uhlobo lokubonisa, njll—kodwa ngokuvamile igxila eduze min-width
futhi max-width
.
Sebenzisa imibuzo yemidiya ngokuzibophezela futhi njengesiqalo kuphela ezithamelini zakho zeselula. Kumaphrojekthi amakhulu, cabanga izisekelo zekhodi ezizinikele hhayi izendlalelo zemibuzo yemidiya.
I-Bootstrap isekela imibuzo embalwa yemidiya efayeleni elilodwa ukuze isize ukwenza amaphrojekthi akho afaneleke kakhudlwana kumadivayisi ahlukene nezinqumo zesikrini. Nakhu okufakiwe:
Ilebula | Ububanzi besakhiwo | Ububanzi bekholomu | Ububanzi be-Gutter |
---|---|---|---|
Ama-Smartphones | 480px nangaphansi | Amakholomu anoketshezi, abukho ububanzi obungashintshi | |
Ama-Smartphones kumathebulethi | 767px nangaphansi | Amakholomu anoketshezi, abukho ububanzi obungashintshi | |
Amathebulethi esithombe | 768px nangaphezulu | 42px | 20px |
Okuzenzakalelayo | 980px nangaphezulu | 60px | 20px |
Isibonisi esikhulu | 1200px nangaphezulu | 70px | 30px |
Ukuqinisekisa ukuthi amadivayisi abonisa amakhasi asabelayo ngendlela efanele, faka i-meta tag yembobo yokubuka.
- <meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
I-Bootstrap ayifaki le mibuzo yemidiya ngokuzenzakalelayo, kodwa ukuqonda nokuyengeza kulula kakhulu futhi kudinga ukusetha okuncane. Unezinketho ezimbalwa zokufaka izici eziphendulayo ze-Bootstrap:
Kungani ungavele uyifake? Iqiniso liyakhulunywa, akuzona zonke izinto ezidinga ukusabela. Esikhundleni sokukhuthaza onjiniyela ukuthi basuse lesi sici, sikubona kungcono kakhulu ukusivumela.
- /* Amafoni we-landscape naphansi */
- @media ( ubuningi - ububanzi : 480px ) { ... }
- /* Ifoni ye-landscape ukuze ifane nethebhulethi */
- @media ( ubuningi - ububanzi : 767px ) { ... }
- /* Ithebhulethi ye-Portrait ibe yizwe kanye nedeskithophu */
- @media ( iminithi - ububanzi : 768px ) kanye ( ubuningi - ububanzi : 979px ) { ... }
- /* Ideskithophu enkulu */
- @media ( iminithi - ububanzi : 1200px ) { ... }
For faster mobile-friendly development, use these basic utility classes for showing and hiding content by device.
Use on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation.
For example, you might show a <select>
element for nav on mobile layouts, but not on tablets or desktops.
Shown here is a table of the classes we support and their effect on a given media query layout (labeled by device). They can be found in responsive.less
.
Class | Phones 480px and below | Tablets 767px and below | Desktops 768px and above |
---|---|---|---|
.visible-phone |
Visible | Hidden | Hidden |
.visible-tablet |
Hidden | Visible | Hidden |
.visible-desktop |
Hidden | Hidden | Visible |
.hidden-phone |
Hidden | Visible | Visible |
.hidden-tablet |
Visible | Hidden | Visible |
.hidden-desktop |
Visible | Visible | Hidden |
Resize your browser or load on different devices to test the above classes.
Green checkmarks indicate that class is visible in your current viewport.
Lapha, omaka abaluhlaza bakhombisa ukuthi ikilasi lifihliwe endaweni yakho yokubuka yamanje.