Bootstrap yakavakirwa pane inopindura 12-column grids, marongero, uye zvikamu.
Bootstrap inoshandisa zvimwe zveHTML zvinhu uye CSS zvivakwa zvinoda kushandiswa kweHTML5 doctype. Isanganise pakutanga kwemapurojekiti ako ese.
- <!DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
Bootstrap inoseta kuratidzwa kwepasirese, kutaipa, uye mataira ekubatanidza. Kunyanya, isu:
margin
pamuviribackground-color: white;
pabody
@baseFontFamily
, @baseFontSize
, uye @baseLineHeight
hunhu seyedu typographic base@linkColor
uye shandisa chinongedzo pasi pemutsara chete pa:hover
Aya masitaera anogona kuwanikwa mukati me scaffolding.less .
NeBootstrap 2, chivharo chekare chekuseta patsva chakasiiwa chichifarira Normalize.css , chirongwa chakaitwa naNicolas Gallagher naJonathan Neal chinopawo simba HTML5 Boilerplate . Nepo isu tichishandisa yakawanda yeNormalize mukati medu reset.less , takabvisa zvimwe zvinhu zvakanangana neBootstrap.
Iyo yakasarudzika Bootstrap grid system inoshandisa gumi nemaviri makoramu, ichigadzira 940px yakafara mudziyo isina anopindura maficha anogoneswa . Iine inopindura CSS faira yakawedzerwa, iyo grid inochinjika kuita 724px uye 1170px yakafara zvichienderana nekutarisa kwako. Pazasi pe767px nzvimbo dzekuona, makoramu acho anova mvura uye akaturikidzana.
Pakurongeka kwemakoramu maviri, gadzira a .row
uye wedzera nhamba yakakodzera .span*
yemakoramu. Sezvo iri gidhi remakoramu gumi nemaviri, imwe neimwe .span*
inotambanudzira huwandu hwemakoramu gumi nemaviri, uye inofanira kugara ichiwedzera kusvika gumi nembiri pamutsara wega wega (kana huwandu hwemakoramu mumubereki).
- <div kirasi = "mutsara" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </ div>
Tichipa muenzaniso uyu, tine .span4
uye .span8
, tichigadzira gumi nemaviri makoramu uye mutsara wakakwana.
Fambisa makoramu kurudyi uchishandisa .offset*
makirasi. Kirasi yega yega inowedzera kumucheto kwekuruboshwe kwekoramu nekoramu yakazara. Semuenzaniso, .offset4
inofamba .span4
pamusoro pemakoramu mana.
- <div kirasi = "mutsara" >
- <div class = "span4" > ... </div>
- <div class = "span3 offset2" > ... </div>
- </ div>
Kuti uise zvirimo zvako neiyo default grid, wedzera nyowani .row
uye seti .span*
yemakoramu mukati meiyo iripo .span*
column. Mitsara yakagara inofanira kusanganisira seti yemakoramu anowedzera kusvika kunhamba yemakoramu emubereki wayo.
- <div kirasi = "mutsara" >
- <div class = "span9" >
- Level 1 column
- <div kirasi = "mutsara" >
- <div class = "span6" > Level 2 </div>
- <div class = "span3" > Level 2 </div>
- </ div>
- </ div>
- </ div>
Iyo fluid grid system inoshandisa percents pachinzvimbo chepixels kune column wides. Iyo ine hunyanzvi hwekupindura hwakafanana neyedu yakagadziriswa gidhi system, kuve nechokwadi chiyero chakakodzera chekiyi skrini yekugadzirisa uye zvishandiso.
Ita chero mutsara "fluid" nekushandura .row
kuita .row-fluid
. Makolamu makirasi anogara akafanana, zvichiita kuti zvive nyore kutenderedza pakati peyakagadziriswa uye fluid grids.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </ div>
Inoshanda nenzira imwechete seyakagadziriswa gidhi system yekumisa: wedzera .offset*
kune chero koramu kuti igadzirise nemakoramu mazhinji.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset2" > ... </div>
- </ div>
Fluid grids anoshandisa dendere zvakasiyana: yega yega nhanho yemakoramu inofanira kuwedzera kusvika gumi nemaviri. Izvi zvinodaro nekuti gidhi remvura rinoshandisa zvikamu, kwete mapikseli, pakuseta upamhi.
- <div class = "row-fluid" >
- <div class = "span12" >
- Fluid 12
- <div class = "row-fluid" >
- <div class = "span6" >
- Mvura 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>
Inopa yakajairwa yakagadziriswa-hupamhi (uye sarudzo inopindura) dhizaini <div class="container">
inodiwa chete.
- <muviri>
- <div kirasi = "mudziyo" >
- ...
- </ div>
- </ body>
Gadzira peji remvura, rine <div class="container-fluid">
makoramu maviri ne-yakanakira maapplication uye zvinyorwa.
- <div class = "container-fluid" >
- <div class = "row-fluid" >
- <div class = "span2" >
- <!--Sidebar content-->
- </ div>
- <div class = "span10" >
- <!--Muviri zvemukati-->
- </ div>
- </ div>
- </ div>
Batidza inopindura CSS mupurojekiti yako nekubatanidza iyo yakakodzera meta tag uye yekuwedzera masitayera mukati megwaro <head>
rako. Kana iwe wakanyora Bootstrap kubva kuGadzirisa peji, iwe unongoda kusanganisira meta tag.
- <meta name = "viewport" content = "width=device-width, first-scale=1.0" >
- <link href = "assets/css/bootstrap-responsive.css" rel = "stylesheet" >
Musoro!Bootstrap haisanganisi maficha anopindura nekukasira panguva ino sezvo zvisiri zvese zvinoda kupindurwa. Panzvimbo pekukurudzira vanogadzira kuti vabvise chimiro ichi, isu tinoona zvakanakisisa kuti tigonese sezvinodiwa.
Mivhunzo yeMedia inobvumira tsika yeCSS zvichibva pane akati wandei mamiriro- retio, upamhi, mhando yekuratidzira, nezvimwe-asi kazhinji inotarisana nekutenderera min-width
uye max-width
.
Shandisa midhiya mibvunzo zvine musoro uye sekutanga kune vateereri vako vefoni. Kune mapurojekiti akakura, funga mabhesi ekodhi akatsaurirwa uye kwete zvikamu zvemibvunzo midhiya.
Bootstrap inotsigira mashoma emibvunzo midhiya mufaira rimwe chete kubatsira kuita kuti mapurojekiti ako ave akakodzera pamidziyo yakasiyana uye skrini yekugadzirisa. Hezvino izvo zvinosanganisirwa:
Label | Layout width | Column width | Gutter width |
---|---|---|---|
Kuratidzwa kukuru | 1200px uye kumusoro | 70px | 30px |
Default | 980px uye kumusoro | 60px | 20px |
Portrait mahwendefa | 768px uye pamusoro | 42px | 20px |
Mafoni kumapiritsi | 767px uye pazasi | Fluid columns, hapana hupamhi hwakagadziriswa | |
Mafoni | 480px uye pasi | Fluid columns, hapana hupamhi hwakagadziriswa |
- /* Desktop hombe */
- @media ( min - width : 1200px ) { ... }
- /* Mufananidzo piritsi kune mamiriro uye desktop */
- @media ( min - width : 768px ) uye ( max - width : 979px ) { ... }
- /* Landscape foni kune mufananidzo piritsi */
- @media ( max - width : 767px ) { ... }
- /* Mafoni emamiriro uye pasi */
- @media ( max - width : 480px ) { ... }
Nekukurumidza kusimudzira nharembozha, shandisa aya makirasi ekushandisa kuratidza uye kuviga zvirimo nemudziyo. Pazasi pane tafura yemakirasi aripo uye maitiro avo pane yakapihwa midhiya yemubvunzo marongerwo (yakanyorwa nemudziyo). Vanogona kuwanikwa mu responsive.less
.
Kirasi | Mafoni767px uye pazasi | Mahwendefa979px kusvika 768px | DesktopsDefault |
---|---|---|---|
.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 |
Shandisa pane yakaganhurwa uye dzivirira kugadzira zvakasiyana zvachose shanduro dzesaiti imwechete. Pane kudaro, zvishandise kuzadzisa mharidzo yemudziyo wega wega. Zvishandiso zvinoteerera hazvifanirwe kushandiswa nematafura, uye nekudaro hazvitsigirwe.
Rezesa browser yako kana kurodha pamidziyo yakasiyana kuti uedze makirasi ari pamusoro.
Green checkmarks inoratidza kuti kirasi inoonekwa mune yako yazvino yekuona.
Pano, macheki egirini anoratidza kuti kirasi yakavanzwa mune yako yazvino yekuona.