An gina Bootstrap akan grid ginshiƙi 12 mai amsawa. Mun kuma haɗa ƙayyadaddun ƙayyadaddun shimfidu da faɗin ruwa bisa wannan tsarin.
Bootstrap yana amfani da abubuwan HTML da kaddarorin CSS waɗanda ke buƙatar amfani da ka'idar HTML5. Tabbatar kun haɗa shi a farkon kowane shafin Bootstrapped a cikin aikin ku.
- <!DOCTYPE html>
- <html lang = "ha" >
- ...
- </html>
A cikin fayil ɗin scaffolding.less , mun saita ainihin nunin duniya, rubutun rubutu, da salon haɗin kai. Musamman, mu:
background-color: white;
akanbody
@baseFontFamily
, @baseFontSize
, da @baseLineHeight
sifofi azaman tushen rubutun mu@linkColor
kuma yi amfani da layin layi kawai a kan:hover
Kamar na Bootstrap 2, sake saitin CSS na al'ada ya samo asali don yin amfani da abubuwa daga Normalize.css , aikin Nicolas Gallagher wanda kuma ke iko da HTML5 Boilerplate .
Har yanzu ana iya samun sabon sake saiti a cikin reset.less , amma tare da abubuwa da yawa da aka cire don taƙaitawa da daidaito.
Tsohuwar tsarin grid da aka bayar a cikin Bootstrap yana amfani da ginshiƙai 12 waɗanda ke samarwa a faɗin 724px, 940px (tsoho ba tare da haɗa CSS mai amsawa ba), da 1170px. A ƙasan wuraren kallon 767px, ginshiƙan sun zama ruwa kuma suna tari a tsaye.
- <div class = "jere" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Kamar yadda aka nuna a nan, za a iya ƙirƙira wani tsari na asali tare da "ginshiƙai" guda biyu, kowannensu yana da adadin ginshiƙai 12 da muka ayyana a matsayin wani ɓangare na tsarin grid ɗin mu.
- <div class = "jere" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset4" > ... </div>
- </div>
Tare da tsarin grid na tsaye (marasa ruwa) a cikin Bootstrap, gida yana da sauƙi. Don shigar da abun cikin ku, kawai ƙara sabon .row
da saitin .span*
ginshiƙai a cikin .span*
ginshiƙi da ke akwai.
Layukan da aka gina su ya kamata su haɗa da saitin ginshiƙai waɗanda suka haɗa har zuwa adadin ginshiƙan iyayensa. Misali, .span3
ya kamata a sanya ginshiƙai biyu masu gida a cikin .span6
.
- <div class = "jere" >
- <div class = "span6" >
- Mataki na 1 shafi
- <div class = "jere" >
- <div class = "span3" > Mataki na 2 </div>
- <div class = "span3" > Mataki na 2 </div>
- </div>
- </div>
- </div>
Tsarin grid na ruwa yana amfani da kaso don faɗin shafi maimakon ƙayyadaddun pixels. Hakanan yana da bambance-bambancen amsa iri ɗaya kamar ƙayyadaddun tsarin grid ɗin mu, yana tabbatar da madaidaitan madaidaitan maɓalli don ƙudurin allo da na'urori.
Yi kowane jeri ruwa ta hanyar canzawa .row
zuwa .row-fluid
. ginshiƙan sun kasance daidai ɗaya, yana mai da shi madaidaici don juyawa tsakanin ƙayyadaddun shimfidar wuri da ruwa.
- <div class = "jere-ruwa" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Gura tare da grid ruwa ya ɗan bambanta: adadin ginshiƙan gida baya buƙatar dacewa da iyaye. Madadin haka, ana sake saita ginshiƙan ku a kowane matakin saboda kowane jere yana ɗaukar 100% na ginshiƙin iyaye.
- <div class = "jere-ruwa" >
- <div class = "span12" >
- Mataki na 1 na shafi
- <div class = "jere-ruwa" >
- <div class = "span6" > Mataki na 2 </div>
- <div class = "span6" > Mataki na 2 </div>
- </div>
- </div>
- </div>
Mai canzawa | Ƙimar ta asali | Bayani |
---|---|---|
@gridColumns |
12 | Adadin ginshiƙai |
@gridColumnWidth |
60px ku | Nisa na kowane shafi |
@gridGutterWidth |
20px ku | Mara kyau sarari tsakanin ginshiƙai |
Gina cikin Bootstrap kaɗan ne na masu canji don keɓance tsohuwar tsarin grid 940px, rubuce a sama. Ana adana duk masu canji na grid a cikin masu canji.less.
Gyara grid yana nufin canza masu @grid*
canji guda uku da sake tattara Bootstrap. Canja masu canjin grid a cikin masu canji.less kuma yi amfani da ɗayan hanyoyi huɗu da aka rubuta don sake tarawa . Idan kana ƙara ƙarin ginshiƙai, tabbatar da ƙara CSS ga waɗanda ke cikin grid.less.
Keɓance grid ɗin yana aiki ne kawai a matakin tsoho, grid 940px. Don kula da abubuwan da suka dace na Bootstrap, za ku kuma tsara grid a cikin amsawa.less.
Tsohuwar kuma mai sauƙi 940px-fadi, shimfidar wuri na tsakiya don kusan kowane gidan yanar gizo ko shafi da aka samar ta guda <div class="container">
.
- <jiki>
- <div class = "kwantena" >
- ...
- </div>
- </ jiki>
<div class="container-fluid">
yana ba da tsarin shafi mai sassauƙa, min- da max- faɗin, da mashigin gefen hagu. Yana da kyau ga apps da docs.
- <div class = "container-fluid" >
- <div class = "jere-ruwa" >
- <div class = "span2" >
- <!-- Abun ciki na gefe-->
- </div>
- <div class = "span10" >
- <!--Abin cikin jiki-->
- </div>
- </div>
- </div>
Tambayoyin watsa labarai suna ba da izinin CSS na al'ada dangane da adadin sharuɗɗa - ragi, faɗin, nau'in nuni, da sauransu-amma yawanci yana mai da hankali a kusa min-width
da max-width
.
Yi amfani da tambayoyin kafofin watsa labarai cikin gaskiya kuma kawai azaman farawa ga masu sauraron wayar hannu. Don manyan ayyuka, yi la'akari da ginshiƙan ƙididdiga na ƙididdiga ba jerin tambayoyin kafofin watsa labarai ba.
Bootstrap yana goyan bayan ɗimbin tambayoyin kafofin watsa labarai a cikin fayil ɗaya don taimakawa yin ayyukan ku mafi dacewa akan na'urori daban-daban da ƙudurin allo. Ga abin da ya haɗa:
Lakabi | Faɗin shimfidar wuri | Faɗin ginshiƙi | Faɗin gutter |
---|---|---|---|
Wayoyin hannu | 480px da ƙasa | ginshiƙan ruwa, babu tsayayyen faɗin | |
Wayoyin hannu zuwa kwamfutar hannu | 767px da ƙasa | ginshiƙan ruwa, babu tsayayyen faɗin | |
Allunan hoto | 768px da sama | 42px ku | 20px ku |
Tsohuwar | 980px kuma sama | 60px ku | 20px ku |
Babban nuni | 1200px da sama | 70px ku | 30px ku |
Don tabbatar da cewa na'urori suna nuna shafuka masu amsa da kyau, haɗa da alamar meta mai duba.
- <meta name = "viewport" abun ciki = "nisa = nisa-na'ura, sikelin farko=1.0" >
Bootstrap baya haɗa waɗannan tambayoyin kafofin watsa labarai ta atomatik, amma fahimta da ƙara su abu ne mai sauƙi kuma yana buƙatar saiti kaɗan. Kuna da ƴan zaɓuɓɓuka don haɗawa da abubuwan amsawa na Bootstrap:
Me zai hana kawai hada shi? Gaskiyar magana, ba duk abin da yake bukatar ya kasance mai amsawa ba. Maimakon ƙarfafa masu haɓakawa don cire wannan fasalin, mun ga zai fi dacewa mu kunna shi.
- /* Wayoyin yanayi da ƙasa */
- @media ( max - nisa : 480px ) { ... }
- /* Wayar shimfidar wuri zuwa kwamfutar hannu mai hoto */
- @media ( max - nisa : 767px ) { ... }
- /* Hoton kwamfutar hannu zuwa wuri mai faɗi da tebur */
- @media ( min - nisa : 768px ) da ( max - nisa : 979px ) { ... }
- /* Babban Desktop */
- @media ( min - nisa : 1200px ) { ... }
Don saurin haɓaka abokantaka na wayar hannu, yi amfani da waɗannan azuzuwan masu amfani don nunawa da ɓoye abun ciki ta na'ura.
Yi amfani da ƙayyadaddun tushe kuma guje wa ƙirƙirar rukunoni daban-daban na rukunin yanar gizon guda ɗaya. Madadin haka, yi amfani da su don dacewa da gabatarwar kowace na'ura.
Misali, zaku iya nuna wani yanki <select>
na nav akan shimfidar wayar hannu, amma ba akan allunan ko tebur ba.
An nuna a nan tebur na azuzuwan da muke tallafawa da tasirinsu akan shimfidar tambayar kafofin watsa labarai da aka bayar (mai lakabin na'ura). Ana iya samun su a cikin responsive.less
.
Class | Wayoyi480px da ƙasa | Allunan767px da ƙasa | Kwamfutoci768px da sama |
---|---|---|---|
.visible-phone |
Ganuwa | Boye | Boye |
.visible-tablet |
Boye | Ganuwa | Boye |
.visible-desktop |
Boye | Boye | Ganuwa |
.hidden-phone |
Boye | Ganuwa | Ganuwa |
.hidden-tablet |
Ganuwa | Boye | Ganuwa |
.hidden-desktop |
Ganuwa | Ganuwa | Boye |
Maimaita girman burauzarku ko lodi akan na'urori daban-daban don gwada azuzuwan da ke sama.
Alamun kore kore suna nuna cewa ajin yana bayyane a wurin kallon ku na yanzu.
Anan, koren cak yana nuna cewa ajin yana ɓoye a wurin kallon ku na yanzu.