Ku endliwa ka swigolonyana

Bootstrap yi akiwile eka gridi ya 12 wa tikholomu leyi hlamulaka. Hi tlhele hi katsa swivumbeko swa fixed- na fluid-width leswi sekeriweke eka sisiteme yoleyo.

Swi lava HTML5 doctype

Bootstrap yi tirhisa swiaki swa HTML na swihlawulekisi swa CSS leswi lavaka ku tirhisiwa ka doctype ya HTML5. Tiyisisa leswaku u yi katsa eku sunguleni ka tluka rin’wana ni rin’wana ra Bootstrapped eka phurojeke ya wena.

  1. <!XITLHOKOVETSELO XA html>
  2. <html lang = "xitsonga" >
  3. ...
  4. </html>

Thayipo na swihlanganisi

Endzeni ka fayili ya scaffolding.less , hi veka nkombiso wa xisekelo wa misava hinkwayo, ku thayipa ni switayele swa swihlanganisi. Hi ku kongoma, hi:

  • Susa margin emirini
  • Seta background-color: white;eka ...body
  • Tirhisa swihlawulekisi swa @baseFontFamily, @baseFontSize, na @baseLineHeighttanihi xisekelo xa hina xa ku thayipa
  • Seta muvala wa xihlanganisi xa misava hinkwayo hi ku tirhisa @linkColorivi u tirhisa switsalo swa xihlanganisi ntsena eka:hover

Seta nakambe hi ku tirhisa Normalize

Ku sukela eka Bootstrap 2, ku tlheriseriwa ka CSS ka ndhavuko ku hundzukile ku tirhisa swiaki leswi humaka eka Normalize.css , phurojeke ya Nicolas Gallagher leyi tlhelaka yi nyika matimba eka HTML5 Boilerplate .

Ku tlheriseriwa lokuntshwa ka ha kumeka eka reset.less , kambe ku ri na swiaki swo tala leswi susiweke leswaku swi koma na ku pakanisa.

1.
1.
1.
1.
1.
1.
1.
1.
1.
1.
1.
1.
4.
4.
4.
4.
8.
6.
6.
12.

Sisiteme ya gridi ya xiviri leyi nyikiweke eka Bootstrap yi tirhisa tikholomu ta 12 leti humesaka hi ku anama ka 724px, 940px (ya xiviri handle ka CSS leyi hlamulaka leyi katsekaka), na 1170px. Ehansi ka 767px viewports, tikholomu ti hundzuka fluid naswona ti stack vertically.

  1. <div tlilasi = "layini" >
  2. <div tlilasi = "span4" > ... </div>
  3. <div tlilasi = "span8" > ... </div>
  4. </div>

Hilaha swi kombisiweke hakona laha, xivumbeko xa xisekelo xi nga endliwa hi "tikholomu" timbirhi, yin'wana na yin'wana yi hlanganisa nhlayo ya tikholomu ta masungulo ta 12 leti hi ti hlamuseleke tanihi xiphemu xa sisiteme ya hina ya giridi.


Ku tlherisela endzhaku tikholomu

4.
4 ku tlheriseriwa endzhaku 4
3 ku tlheriseriwa endzhaku 3
3 ku tlheriseriwa endzhaku 3
8 ku tlheriseriwa endzhaku 4
  1. <div tlilasi = "layini" >
  2. <div tlilasi = "span4" > ... </div>
  3. <div tlilasi = "span4 offset4" > ... </div>
  4. </div>

Tikholomu to endla swisaka

Hi sisiteme ya grid ya static (non-fluid) eka Bootstrap, ku endla swisaka swa olova. Ku nest nhundzu ya wena, engetela ntsena leyintshwa .rowna sete ya .span*tikholomu endzeni ka .span*kholomo leyi nga kona.

Xikombiso

Tilayini leti pfanganisiweke ti fanele ku katsa sete ya tikholomu leti hlanganisaka nhlayo ya tikholomu ta mutswari wa yona. Hi xikombiso, .span3tikholomu timbirhi leti hlanganisiweke ti fanele ti vekiwa endzeni ka .span6.

Level 1 ya kholomo
Xiyimo xa 2
Xiyimo xa 2
  1. <div tlilasi = "layini" >
  2. < tlilasi ya div = "span6" >
  3. Kholomo ya Level 1
  4. <div tlilasi = "layini" >
  5. <div class = "span3" > Xiyimo xa 2 </div>
  6. <div class = "span3" > Xiyimo xa 2 </div>
  7. </div>
  8. </div>
  9. </div>

Tikholomu ta mati

1.
1.
1.
1.
1.
1.
1.
1.
1.
1.
1.
1.
4.
4.
4.
4.
8.
6.
6.
12.

Tiphesente, ku nga ri ti- pixels

Endlelo ra giridi ya mati ri tirhisa tiphesente eka ku anama ka tikholomu ematshan’weni ya tipikseli leti nga cinciki. Yi tlhela yi va na ku hambana loku hlamulaka loku fanaka na sisiteme ya hina ya giridi leyi nga cinciki, ku tiyisisa swipimelo leswi faneleke swa swiboho swa xikirini xa nkoka na switirhisiwa.

Tilayini ta mati

Endla leswaku layini yihi na yihi yi khuluka hi ku cinca ntsena yi .rowva .row-fluid. Tikholomu ti tshama ti ri tano hi ku kongoma, leswi endlaka leswaku swi va super straightforward ku flip exikarhi ka fixed na fluid layouts.

Ku fungha swilo

  1. <div class = "xigwitsirisi xa layini" >
  2. <div tlilasi = "span4" > ... </div>
  3. <div tlilasi = "span8" > ... </div>
  4. </div>

Ku endla swisaka swa mati

Ku endla swisaka hi ti fluid grids swihambanile nyana: nhlayo ya tikholomu leti pfanganisiweke ayi lavi ku fambisana na mutswari. Ematshan’wini ya sweswo, tikholomu ta wena ti tlhela ti vekiwa eka xiyimo xin’wana na xin’wana hikuva layini yin’wana na yin’wana yi teka 100% wa kholomo ya mutswari.

Xihalaki 12
Xihalaki 6
Xihalaki 6
  1. <div class = "xigwitsirisi xa layini" >
  2. < tlilasi ya div = "span12" >
  3. Level 1 ya kholomo
  4. <div class = "xigwitsirisi xa layini" >
  5. <div class = "span6" > Xiyimo xa 2 </div>
  6. <div class = "span6" > Xiyimo xa 2 </div>
  7. </div>
  8. </div>
  9. </div>
Swilo leswi cinca-cincaka Nhlayo ya xiviri Nhlamuselo
@gridColumns 12. Nhlayo ya tikholomu
@gridColumnWidth 60px Ku anama ka kholomo yin’wana ni yin’wana
@gridGutterWidth 20px Ndhawu leyi nga riki yinene exikarhi ka tikholomu

Swilo leswi cinca-cincaka eka LESS

Ku akiwile eka Bootstrap i swilo swo hlayanyana leswi cinca-cincaka swo cinca-cinca sisiteme ya gridi ya 940px ya ntolovelo, leswi tsariweke laha henhla. Swilo hinkwaswo leswi cinca-cincaka swa gridi swi hlayisiwa eka swilo leswi cinca-cincaka.less.

Ndlela yo endla swilo hi ku landza swilaveko swa wena

Ku cinca gridi swi vula ku cinca swilo swinharhu @grid*leswi cinca-cincaka ni ku tlhela u hlengeleta Bootstrap. Cinca swilo leswi cinca-cincaka swa gridi eka swilo leswi cinca-cincaka.less ivi u tirhisa yin’wana ya tindlela ta mune leti tsariweke ku hlengeleta nakambe . Loko u engetela tikholomu tin’wana, tiyiseka leswaku u engetela CSS ya lava nga eka grid.less.

Ku tshama u ri karhi u hlamula

Ku lulamisiwa ka gridi ku tirha ntsena eka xiyimo xa ntolovelo, gridi ya 940px. Ku hlayisa swiphemu leswi hlamulaka swa Bootstrap, u ta tlhela u boheka ku lulamisa tigridi eka responsive.less.

Xivumbeko lexi nga cinciki

Xivumbeko xa xiviri ni xo olova xa 940px-wide, lexi nga exikarhi xa kwalomu ka webusayiti yin’wana ni yin’wana kumbe tluka leri nyikeriweke hi yin’we <div class="container">.

  1. <miri>
  2. <div class = "xigwitsirisi" >
  3. ...
  4. </div>
  5. </body>

Xivumbeko xa mati

<div class="container-fluid">yi nyika xivumbeko xa pheji lexi cinca-cincaka, min- na max-widths, na sidebar ya voko ra ximatsi. Swi kahle eka ti apps na ti docs.

  1. <div class = "xigwitsirisi-xigwitsirisi" >
  2. <div class = "xigwitsirisi xa layini" >
  3. < tlilasi ya div = "span2" >
  4. <!--Nhundzu ya le tlhelo-->
  5. </div>
  6. < tlilasi ya div = "span10" >
  7. <!--Nhundzu ya miri-->
  8. </div>
  9. </div>
  10. </div>

Switirhisiwa leswi hlamulaka

Leswi va swi endlaka

Swivutiso swa midiya swi pfumelela CSS ya ntolovelo leyi sekeriweke eka swiyimo swo hlayanyana—swiringaniso, ku anama, muxaka wa nkombiso, na swin’wana—kambe hi ntolovelo swi kongomisa ku rhendzela min-widthna max-width.

  • Cinca ku anama ka kholomo eka giridi ya hina
  • Stack elements ematshan’wini ya float kun’wana na kun’wana laha swi lavekaka kona
  • Cinca sayizi ya tinhloko-mhaka ni matsalwa leswaku swi faneleka swinene eka switirhisiwa

Tirhisa swivutiso swa vuhangalasi bya mahungu hi vutihlamuleri naswona ntsena tanihi masungulo eka vayingiseri va wena va tiselfoni. Eka tiphurojeke letikulu, endla anakanya hi swisekelo swa khodi leswi tinyiketeleke ku nga ri swiphemu swa swivutiso swa vuhangalasi bya mahungu.

Switirhisiwa leswi seketeriwaka

Bootstrap yi seketela swivutiso swo hlayanyana swa midiya eka fayili yin’we ku pfuneta ku endla leswaku tiphurojeke ta wena ti faneleka swinene eka switirhisiwa swo hambana na swiboho swa xikirini. Hi leswi swi katsekaka:

Lebulu Ku anama ka layout Ku anama ka kholomo Ku anama ka gutter
Ti-smartphone 480px na le hansi Tikholomu ta mati, ku hava ku anama loku nga cinciki
Ti-smartphone ku ya eka tithebulete 767px na le hansi Tikholomu ta mati, ku hava ku anama loku nga cinciki
Swiphepherhele swa swifaniso 768px na le henhla 42px 20px
Ku tlula 980px ku ya ehenhla 60px 20px
Xikombiso lexikulu 1200px ku ya ehenhla 70px 30px

Swi lava meta tag

Ku tiyisisa leswaku switirhisiwa swi kombisa matluka lama hlamulaka kahle, katsa thegi ya meta ya viewport.

  1. <meta name = "viewport" content = "ku anama=ku anama ka xitirhisiwa, xikalo xo sungula=1.0" >

Ku tirhisa swivutiso swa swihangalasamahungu

Bootstrap a yi katsi hi ku tisungulela swivutiso leswi swa midiya, kambe ku swi twisisa ni ku swi engetela swa olova swinene naswona swi lava ku lulamisiwa lokutsongo. U na swihlawulekisi swi nga ri swingani swo katsa swihlawulekisi leswi hlamulaka swa Bootstrap:

  1. Tirhisa vuhundzuluxeri lebyi hlamulaka lebyi hlengeletiweke, bootstrap-responsive.css
  2. Engetelani @import "responsive.less" u tlhela u hlengeleta Bootstrap
  3. Cinca u tlhela u hlengeleta responsive.less tanihi fayili leyi hambaneke

Ha yini u nga yi katsi ntsena? Ku vula ntiyiso, a hi xin’wana ni xin’wana lexi lavaka ku hlamula. Ematshan’weni yo khutaza vaendli va swilo leswaku va susa xiyenge lexi, hi ehleketa kahle leswaku hi xi endla xi tirha.

  1. /* Tifoyini ta landscape na le hansi */
  2. @media ( max -ku anama : 480px ) { ... }.
  3.  
  4. /* Foni ya landscape ku ya eka thebulete ya xifaniso */
  5. @media ( max -ku anama : 767px ) { ... }.
  6.  
  7. /* Xifaniso xa thebulete eka landscape na desktop */
  8. @media ( min - width : 768px ) na ( max - width : 979px ) { ... }.
  9.  
  10. /* Desktop leyikulu */
  11. @media ( min -ku anama : 1200px ) { ... }.

Titlilasi ta vukorhokeri leti hlamulaka

Xana i yini

Ku kuma nhluvukiso wo hatlisa lowu nga na xinghana eka tiselfoni, tirhisa titlilasi leti ta xisekelo ta vukorhokeri byo kombisa na ku tumbeta swilo hi xitirhisiwa.

Xana u fanele u tirhisa rini

Tirhisa hi mpimo lowu pimiweke naswona papalata ku endla vuhundzuluxeri lebyi hambaneke hi ku helela bya sayiti yin’we. Ematshan’weni ya sweswo, ti tirhise leswaku u tatisa ndlela leyi xitirhisiwa xin’wana ni xin’wana xi vulavulaka ha yona.

Xikombiso, u nga ha kombisa <select>elemente ya nav eka swivumbeko swa tiselfoni, kambe ku nga ri eka tithebulete kumbe tidesktop.

Titlilasi to seketela

Laha ku kombisiwile tafula ra titlilasi leti hi ti seketelaka na vuyelo bya tona eka xivumbeko xa xivutiso xa midiya lexi nyikiweke (lexi leteriweke hi xitirhisiwa). Swi nga kumeka eka responsive.less.

Tlilasi Tifoni480px na le hansi Tiphilisi767px na le hansi Tidesktop768px na le henhla
.visible-phone Swi vonaka
.visible-tablet Swi vonaka
.visible-desktop Swi vonaka
.hidden-phone Swi vonaka Swi vonaka
.hidden-tablet Swi vonaka Swi vonaka
.hidden-desktop Swi vonaka Swi vonaka

Xikambelo xa xiyimo

Cinca sayizi ya browser ya wena kutani u layicha eka switirhisiwa swo hambana-hambana leswaku u ringeta titlilasi leti nga laha henhla.

Swi vonaka eka...

Swikombiso swa rihlaza swi kombisa leswaku tlilasi ya vonaka eka xivono xa wena xa sweswi.

  • Riqingho✔ Foni
  • Xiphepherhele xa✔ Xiphepherhele
  • Desktop ya le henhla✔ Xitirhisiwa xa le desktop

Ku fihliwile eka...

Laha, swikombiso swa rihlaza swi kombisa leswaku tlilasi yi fihliwile eka xivono xa wena xa sweswi.

  • Riqingho✔ Foni
  • Xiphepherhele xa✔ Xiphepherhele
  • Desktop ya le henhla✔ Xitirhisiwa xa le desktop