Bootstrap wuxuu ku dhisan yahay shabag 12-column ah oo ka jawaabaya. Waxa kale oo aanu ku darnay qaabayn go'an iyo ballac dareere ah oo ku salaysan nidaamkaas.
Bootstrap waxay isticmaashaa walxaha HTML iyo sifooyinka CSS ee u baahan isticmaalka HTML5 doctype. Hubi inaad ku darto bilawga bog kasta oo Bootstrapped ee mashruucaaga.
- <!DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
Gudaha faylka scaffolding.less , waxaanu dejinay bandhig caalami ah oo aasaasi ah, qoraal qoraal ah, iyo qaababka isku xidhka. Gaar ahaan, waxaanu:
background-color: white;
dhejibody
@baseFontFamily
, @baseFontSize
, iyo @baseLineHeight
sifooyinka sida saldhigga qoraaleedkayaga@linkColor
oo mari xariiqyada hoose oo keliya:hover
Sida Bootstrap 2, dib-u-dejinta dhaqanka ee CSS ayaa u kobcay si ay u isticmaasho walxaha Normalize.css , mashruuca Nicolas Gallagher kaas oo sidoo kale awood u leh HTML5 Boilerplate .
Dib u habeynta cusub ayaa weli laga heli karaa reset.less , laakiin leh waxyaabo badan oo laga saaray si kooban iyo saxsanaan.
Nidaamka grid-ka caadiga ah ee lagu bixiyo Bootstrap wuxuu isticmaalaa 12 tiir oo bixiya ballaca 724px, 940px (sida caadiga ah iyada oo aan CSS jawaab celin ah lagu darin), iyo 1170px. Ka hooseeya 767px daawashada, tiiraryadu waxay noqonayaan dareere oo si toos ah u dul saaran.
- <div class = " saf" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Sida halkan ku cad, qaabayn aasaasi ah ayaa lagu abuuri karaa laba "tiir", mid kastaa wuxuu ka kooban yahay tiro ka mid ah 12 tiirar ee aasaaska ah ee aan ku qeexnay qayb ka mid ah nidaamka xariijinta.
- <div class = " saf" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset4" > ... </div>
- </div>
Iyada oo la raacayo nidaamka shabagga static (aan dareere ahayn) ee Bootstrap, buul-ku-dhigiddu waa sahlan tahay. Si aad buulka ugu dhejiso macluumaadkaaga, kaliya ku dar tiirar cusub .row
iyo set oo .span*
tiirar ah oo ku dhex jira .span*
tiir jira.
Safafka buulka leh waa in ay ku jiraan tiro tiirar ah oo isku geynaya tirada tiirarka waalidkiisa. Tusaale ahaan, laba .span3
tiir oo buul ah waa in lagu dhejiyaa gudaha a .span6
.
- <div class = " saf" >
- <div class = "span6" >
- Heerka 1 tiirka
- <div class = " saf" >
- <div class = "span3" > Heerka 2 </div>
- <div class = "span3" > Heerka 2 </div>
- </div>
- </div>
- </div>
Nidaamka xadhkaha dareeraha ah wuxuu isticmaalaa boqolleyda ballaca tiirka halkii uu ka isticmaali lahaa pixels go'an. Waxa kale oo ay leedahay kala duwanaansho jawaab celin ah oo la mid ah nidaamkayaga qulqulka go'an, iyada oo hubinaysa saamiga saxda ah ee xallinta shaashadda muhiimka ah iyo qalabka.
Samee dareere kasta adigoo si fudud u .row
beddelaya .row-fluid
. Tiirarku waa isku mid, taas oo ka dhigaysa mid toos ah in la isku rogo inta u dhaxaysa qaababka go'an iyo dareeraha.
- <div class = "dareere-dheecaan" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Buulka leh shabaqyada dareeraha ah ayaa xoogaa kala duwan: tirada tiirarka buulka ah uma baahna inay u dhigmaan waalidka. Taa baddalkeeda, tiirarkaaga dib ayaa loo dejiyay heer kasta sababtoo ah saf kastaa wuxuu qaataa 100% tiirka waalidka.
- <div class = "dareere-dheecaan" >
- <div class = "span12" >
- Heerka 1 ee tiirka
- <div class = "dareere-dheecaan" >
- <div class = "span6" > Heerka 2 </div>
- <div class = "span6" > Heerka 2 </div>
- </div>
- </div>
- </div>
La beddeli karo | Qiimaha caadiga ah | Sharaxaada |
---|---|---|
@gridColumns |
12 | Tirada tiirarka |
@gridColumnWidth |
60px | Ballaca tiir kasta |
@gridGutterWidth |
20px | Meel xun oo u dhaxaysa tiirarka |
Lagu dhisay Bootstrap waa tiro doorsoomayaal ah oo loogu talagalay habaynta nidaamka grid-ka caadiga ah ee 940px, ee kor lagu diiwaangeliyay. Dhammaan doorsoomayaasha shabkada waxa lagu kaydiyaa doorsoomayaal.less.
Wax ka beddelka shabkada macneheedu waa beddelka saddexda @grid*
doorsoome iyo dib-u-ururinta Bootstrap. Beddel doorsoomayaasha sharoobada doorsoomayaal.wax yar oo isticmaal mid ka mid ah afarta siyaabood ee la diiwaan galiyay si dib loo ururiyo . Haddii aad ku darayso tiirar badan, hubi inaad ku darto CSS kuwa ku jira grid.less.
Habaynta shabakadu waxay ka shaqeysaa kaliya heerka caadiga ah, 940px grid. Si aad u ilaaliso dhinacyada ka jawaabaya Bootstrap, waa inaad sidoo kale u habayn kartaa shabaqyada si ka jawaab celin ah.
Qaabka caadiga ah oo fudud ee 940px-ballaaran, qaabaynta xuddun u ah kaliya degel kasta ama bog uu bixiyo hal <div class="container">
.
- <jir>
- <div class = "konteenar" >
- ...
- </div>
- </body>
<div class="container-fluid">
wuxuu siinayaa qaab-dhismeedka bogga dabacsan, min- iyo ballac-xareed, iyo dhinaca bidix ee bidix. Way ku fiican tahay abka iyo dukumentiyada
- <div class = "container-fluid" >
- <div class = "dareere-dheecaan" >
- <div class = "span2" >
- <!--Content sidebar-->
- </div>
- <div class = "span10" >
- <!--Qoddobka Jidhka-->
- </div>
- </div>
- </div>
Weydiimaha warbaahintu waxay u oggolaanayaan CSS caado ah oo ku salaysan tiro shuruudo ah - saamiyo, ballaca, nooca bandhigga, iwm - laakiin badanaa waxay diiradda saaraan hareeraha min-width
iyo max-width
.
U isticmaal su'aalaha warbaahinta si mas'uuliyadi ku jirto oo kaliya sida bilawga dhagaystayaashaada mobaylka. Mashruucyada waaweyn, ka fiirso saldhigyada koodka ee ha u eegin lakabyada weydiimaha warbaahinta.
Bootstrap waxay taageertaa su'aalo yar oo warbaahin ah oo ku jira hal fayl si ay uga caawiso inay mashaariicdaada ka dhigaan kuwo ku habboon aaladaha kala duwan iyo xallinta shaashadda. Waa kuwan waxa ku jira:
Summada | Balaadhka qaabaynta | Ballaca tiirka | Ballaca godka |
---|---|---|---|
Taleefannada casriga ah | 480px iyo ka hooseeya | Tiirar dareere ah, oo aan lahayn ballac go'an | |
Taleefanka casriga ah ee loo yaqaan tablets | 767px iyo ka hooseeya | Tiirar dareere ah, oo aan lahayn ballac go'an | |
Kiniinnada sawirka | 768px iyo wixii ka sareeya | 42px | 20px |
Asal ahaan | 980px iyo in ka badan | 60px | 20px |
Bandhig weyn | 1200px iyo in ka badan | 70px | 30px |
Si loo hubiyo in qalabku u soo bandhigo bogag jawaab celin ah si sax ah, ku dar calaamadda meta ee daawashada.
- <meta name = "viewport" content = "ballad=qalabka-ballaadhka, bilowga-miisaanka=1.0" >
Bootstrap si toos ah kuma jiraan weydiimahan warbaahinta, laakiin fahamka iyo ku darida iyaga aad ayay u fududahay waxayna u baahan tahay habayn yar. Waxaad haysataa dhawr ikhtiyaar oo aad ku dari karto sifooyinka ka jawaabaya Bootstrap:
Maxaa loogu dari waayay? Run ahaantii, wax walba uma baahna inay noqdaan kuwo ka jawaabaya. Halkii aan ku dhiirigelin lahayn horumariyayaasha inay ka saaraan sifadan, waxaan ogaanay sida ugu wanaagsan ee aan awood u yeelan karno.
- /* Taleefannada muuqaalka iyo hoos */
- @media ( ugu badnaan - ballac : 480px ) { ... }
- /* Taleefan muuqaal ah oo loogu talagalay kiniinka sawirka */
- @media ( ugu badnaan - ballac : 767px ) { ... }
- /* Kiniin sawir leh oo ku socda muuqaalka iyo miiska */
- @media ( daq - ballac : 768px ) iyo ( ugu badnaan - ballac : 979px ) { ... }
- /* desktop weyn */
- @media ( daq - balac : 1200px ) { ... }
Horumarka saaxiibtinimo ee moobilka dhaqsaha badan, u isticmaal fasaladan tamarta aasaasiga ah si aad u muujiso oo aad ugu qariso waxa ku jira aalad.
U isticmaal si xaddidan oo iska ilaali abuurista noocyo kala duwan oo isla goobta ah. Taa beddelkeeda, u isticmaal si aad u dhammaystirto soo bandhigida qalab kasta.
Tusaale ahaan, waxa laga yaabaa inaad tusto <select>
curiye nav qaab-dhismeedka moobaylka, laakiin maaha tablatooyinka ama miisaska.
Halkan waxaa lagu muujiyey shaxda fasalada aanu taageerno iyo saamaynta ay ku leeyihiin qaabka su'aal warbaahineed ee la bixiyay (ku calaamadeeyay qalab). Waxa laga heli karaa responsive.less
.
Fasalka | Telefoonada480px iyo ka hooseeya | Kiniinnada767px iyo ka hooseeya | Miisaanka768px iyo wixii ka sareeya |
---|---|---|---|
.visible-phone |
Muuqda | Qarsoon | Qarsoon |
.visible-tablet |
Qarsoon | Muuqda | Qarsoon |
.visible-desktop |
Qarsoon | Qarsoon | Muuqda |
.hidden-phone |
Qarsoon | Muuqda | Muuqda |
.hidden-tablet |
Muuqda | Qarsoon | Muuqda |
.hidden-desktop |
Muuqda | Muuqda | Qarsoon |
Dib u qiyaas biraawsarkaaga ama ku shub qalab kala duwan si aad u tijaabiso fasalada sare
Calaamadaha cagaarka ah waxay muujinayaan in fasalka uu ka muuqanayo aragtidaada hadda.
Halkan, calaamadaha cagaarka ah waxay muujinayaan in fasalka uu ku qarsoon yahay aragtidaada hadda.