Bootstrap yakavakirwa pane inopindura 12-column grid. Isu takasanganisira yakagadziriswa- uye fluid-width marongero anoenderana neiyo system.
Bootstrap inoshandisa HTML zvinhu uye CSS zvivakwa zvinoda kushandiswa kweHTML5 doctype. Ita shuwa yekuisanganisira pakutanga kweese Bootstrapped peji muprojekiti yako.
- <!DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
Mukati me scaffolding.less faira, tinoseta basic display global, typography, and link styles. Kunyanya, isu:
background-color: white;
pabody
@baseFontFamily
, @baseFontSize
, uye @baseLineHeight
hunhu seyedu typography base@linkColor
uye shandisa chinongedzo pasi pemutsara chete pa:hover
Kubva paBootstrap 2, iyo yechinyakare CSS reset yakashanduka kuita kushandisa zvinhu kubva kuNormalize.css , chirongwa chakaitwa naNicolas Gallagher chinopawo simba HTML5 Boilerplate .
Iyo itsva reset ichiri kuwanikwa mune reset.less , asi nezvinhu zvakawanda zvakabviswa nekuda kwekupfupika uye nemazvo.
Iyo yakasarudzika grid sisitimu yakapihwa muBootstrap inoshandisa gumi nemaviri makoramu anopa kunze pahupamhi hwe724px, 940px (default isina inopindura CSS inosanganisirwa), uye 1170px. Pazasi pe767px nzvimbo dzekuona, makoramu acho anova mvura uye akaturikidzana.
- <div kirasi = "mutsara" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </ div>
Sezvinoratidzwa pano, dhizaini yekutanga inogona kugadzirwa iine "makoramu" maviri, imwe neimwe ichitora akati wandei emakoramu gumi nemaviri atakatsanangura sechikamu chegridi system yedu.
- <div kirasi = "mutsara" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset4" > ... </div>
- </ div>
Neiyo static (isina-fluid) grid system muBootstrap, nesting iri nyore. Kuti uise zvirimo zvako, ingo wedzera nyowani .row
uye seti .span*
yemakoramu mukati meiyo iripo .span*
column.
Mitsara yakagara inofanira kusanganisira seti yemakoramu anowedzera kusvika kunhamba yemakoramu emubereki wake. Semuenzaniso, makoramu maviri akaiswa madendere .span3
anofanirwa kuiswa mukati me .span6
.
- <div kirasi = "mutsara" >
- <div class = "span6" >
- Level 1 column
- <div kirasi = "mutsara" >
- <div class = "span3" > Level 2 </div>
- <div class = "span3" > Level 2 </div>
- </ div>
- </ div>
- </ div>
Iyo fluid grid system inoshandisa mapercents kuhupamhi hwekoramu panzvimbo yemapikisi akagadziriswa. Iyo ine zvakare yakafanana inopindura misiyano seyedu yakagadziriswa gidhi system, ichiva nechokwadi chezviyero zvakafanira zvekiyi skrini yekugadzirisa uye zvishandiso.
Ita chero mutsara unyoro nekungochinja .row
kuita .row-fluid
. Makoramu anogara akafanana, zvichiita kuti zvive nyore kutenderera pakati pezvakagadziriswa uye zvinyoro zvimiro.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </ div>
Nesting ine fluid grids yakati siyanei: iyo nhamba yemakoramu akaiswa madendere haidi kuenderana nemubereki. Pane kudaro, makoramu ako anogadzikiswa padanho rega rega nekuti mutsara wega wega unotora 100% yekoramu yevabereki.
- <div class = "row-fluid" >
- <div class = "span12" >
- Chikamu 1 chechikamu
- <div class = "row-fluid" >
- <div class = "span6" > Level 2 </div>
- <div class = "span6" > Level 2 </div>
- </ div>
- </ div>
- </ div>
Variable | Default value | Tsanangudzo |
---|---|---|
@gridColumns |
12 | Nhamba yezvikamu |
@gridColumnWidth |
60px | Kufara kwembiru imwe neimwe |
@gridGutterWidth |
20px | Negative nzvimbo pakati pembiru |
Yakavakwa muBootstrap mashoma mashoma ekugadzirisa iyo default 940px grid system, yakanyorwa pamusoro. Zvose zvakasiyana-siyana zvegridi zvakachengetwa muzvinyorwa.zvishoma.
Kugadzirisa grid kunoreva kushandura matatu @grid*
akasiyana uye kudzorera Bootstrap. Shandura mabhidhiri egidhi mumabhii.less uye shandisa imwe yenzira ina dzakanyorwa kuunganidza . Kana uri kuwedzera mamwe makoramu, iva nechokwadi chekuwedzera CSS kune avo vari grid.less.
Kugadziriswa kwegridi kunongoshanda padanho rekutanga, iyo 940px grid. Kuti uchengetedze zvinoteerera zveBootstrap, iwe zvakare uchafanirwa kugadzirisa magidhi mukupindura.less.
Iyo yakasarudzika uye yakapusa 940px-yakafara, yakatarisana dhizaini yeinongoita chero webhusaiti kana peji rinopihwa neamwechete <div class="container">
.
- <muviri>
- <div kirasi = "mudziyo" >
- ...
- </ div>
- </ body>
<div class="container-fluid">
inopa inochinjika peji chimiro, min- uye max-upamhi, uye kuruboshwe-kuruboshwe. Yakanakira maapplication uye madoku.
- <div class = "container-fluid" >
- <div class = "row-fluid" >
- <div class = "span2" >
- <!--Sidebar content-->
- </ div>
- <div class = "span10" >
- <!--Muviri zvemukati-->
- </ div>
- </ div>
- </ div>
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 |
---|---|---|---|
Mafonifoni | 480px uye pasi | Fluid columns, hapana hupamhi hwakagadziriswa | |
Smartphones kune mahwendefa | 767px uye pazasi | Fluid columns, hapana hupamhi hwakagadziriswa | |
Portrait mahwendefa | 768px uye pamusoro | 42px | 20px |
Default | 980px uye kumusoro | 60px | 20px |
Kuratidzwa kukuru | 1200px uye kumusoro | 70px | 30px |
Kuti uone kuti zvishandiso zvinoratidzira mapeji anoteerera zvakanaka, sanganisira iyo yekutarisa meta tag.
- <meta name = "viewport" content = "width=device-width, first-scale=1.0" >
Bootstrap haingosanganisire iyi mibvunzo midhiya, asi kunzwisisa nekuwedzera kuri nyore kwazvo uye kunoda kushomeka kuseta. Iwe une mashoma sarudzo dzekusanganisira anopindura maficha eBootstrap:
Wadii kungoisanganisira? Chokwadi kutaurirwa, hazvisi zvese zvinoda kupindurwa. Panzvimbo pekukurudzira vanogadzira kuti vabvise chimiro ichi, isu tinoona zviri nani kuti tigone kugonesa.
- /* Mafoni emamiriro uye pasi */
- @media ( max - width : 480px ) { ... }
- /* Landscape foni kune mufananidzo piritsi */
- @media ( max - width : 767px ) { ... }
- /* Mufananidzo piritsi kune mamiriro uye desktop */
- @media ( min - width : 768px ) uye ( max - width : 979px ) { ... }
- /* Desktop hombe */
- @media ( min - width : 1200px ) { ... }
Nekukurumidza kusimudzira nharembozha, shandisa aya makirasi ekushandisa ekuratidza uye kuviga zvirimo nemudziyo.
Shandisa pane yakaganhurwa uye dzivirira kugadzira zvakasiyana zvachose shanduro dzesaiti imwechete. Pane kudaro, zvishandise kuzadzisa mharidzo yemudziyo wega wega.
Semuenzaniso, unogona kuratidza <select>
chinhu che nav pane nharembozha, asi kwete pamatafura kana desktops.
Inoratidzwa pano tafura yemakirasi atinotsigira uye maitiro awo pane yakapihwa midhiya yemubvunzo marongerwo (yakanyorwa nemudziyo). Vanogona kuwanikwa mu responsive.less
.
Kirasi | Mafoni480px uye pasi | Mahwendefa767px uye pazasi | Desktops768px uye pamusoro |
---|---|---|---|
.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 |
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.