Bootstrap an gina shi akan grid ginshiƙai 12 masu amsawa, shimfidu, da abubuwan haɗin gwiwa.
Bootstrap yana amfani da wasu abubuwan HTML da kaddarorin CSS waɗanda ke buƙatar amfani da tsarin HTML5. Hada shi a farkon duk ayyukan ku.
- <!DOCTYPE html>
- <html lang = "ha" >
- ...
- </html>
Bootstrap yana saita ainihin nunin duniya, rubutun rubutu, da salon haɗin kai. Musamman, mu:
margin
a jikibackground-color: white;
akanbody
@baseFontFamily
, @baseFontSize
, da @baseLineHeight
sifofi azaman tushen rubutun mu@linkColor
kuma yi amfani da layin layi kawai a kan:hover
Ana iya samun waɗannan salon a cikin scaffolding.less .
Tare da Bootstrap 2, an jefar da tsohuwar toshewar sake saiti a cikin ni'imar Normalize.css , aikin Nicolas Gallagher da Jonathan Neal wanda kuma ke iko da HTML5 Boilerplate . Yayin da muke amfani da yawa na Normalize a cikin reset.less , mun cire wasu abubuwa musamman don Bootstrap.
Tsohuwar tsarin grid na Bootstrap yana amfani da ginshiƙai 12 , yana yin babban akwati mai faɗin 940px ba tare da kunna fasali masu amsawa ba. Tare da ƙara fayil ɗin CSS mai amsa, grid ɗin ya dace da zama 724px da faɗin 1170px ya danganta da kallon kallon ku. A ƙasan wuraren kallon 767px, ginshiƙan sun zama ruwa kuma suna tari a tsaye.
Don shimfidar ginshiƙi biyu mai sauƙi, ƙirƙira .row
kuma ƙara adadin .span*
ginshiƙan da suka dace. Da yake wannan grid mai shafi 12 ne, kowanne .span*
ya faɗi adadin waɗannan ginshiƙai 12, kuma koyaushe yakamata ya ƙara har zuwa 12 ga kowane jere (ko adadin ginshiƙai a cikin iyaye).
- <div class = "jere" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
An ba da wannan misalin, muna da .span4
kuma .span8
, yin ginshiƙai 12 duka da cikakken jeri.
Matsar da ginshiƙai zuwa dama ta amfani .offset*
da azuzuwan. Kowane aji yana ƙara gefen hagu na ginshiƙi da gabaɗayan ginshiƙi. Misali, .offset4
yana motsawa .span4
sama da ginshiƙai huɗu.
- <div class = "jere" >
- <div class = "span4" > ... </div>
- <div class = "span3 offset2" > ... </div>
- </div>
Don shigar da abun cikin ku tare da tsoho grid, ƙara sabon .row
da saitin .span*
ginshiƙai a cikin .span*
ginshiƙi da ke akwai. Layukan da aka kafa ya kamata su haɗa da saitin ginshiƙai waɗanda ke ƙara adadin ginshiƙan iyayensa.
- <div class = "jere" >
- <div class = "span9" >
- Mataki na 1 shafi
- <div class = "jere" >
- <div class = "span6" > Mataki na 2 </div>
- <div class = "span3" > Mataki na 2 </div>
- </div>
- </div>
- </div>
Tsarin grid na ruwa yana amfani da kashi-kashi maimakon pixels don faɗin shafi. Yana da damar amsa iri ɗaya kamar ƙayyadaddun tsarin grid ɗin mu, yana tabbatar da madaidaitan madaidaitan maɓalli don ƙudurin allo da na'urori.
Yi kowane jere "ruwa" ta canza .row
zuwa .row-fluid
. Azuzuwan ginshiƙi sun kasance daidai ɗaya, yana sauƙaƙa juyawa tsakanin kafaffen grid da ruwa.
- <div class = "jere-ruwa" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Yana aiki daidai da ƙayyadaddun tsarin tsarin grid: ƙara .offset*
zuwa kowane shafi don daidaitawa ta ginshiƙan da yawa.
- <div class = "jere-ruwa" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset2" > ... </div>
- </div>
Gilashin ruwa suna amfani da gida daban-daban: kowane matakin ginshiƙai ya kamata ya ƙara har zuwa ginshiƙai 12. Wannan saboda grid na ruwa yana amfani da kaso, ba pixels ba, don saita faɗin.
- <div class = "jere-ruwa" >
- <div class = "span12" >
- Ruwa 12
- <div class = "jere-ruwa" >
- <div class = "span6" >
- Ruwa 6
- <div class = "jere-ruwa" >
- <div class = "span6" > Ruwa 6 </div>
- <div class = "span6" > Ruwa 6 </div>
- </div>
- </div>
- <div class = "span6" > Ruwa 6 </div>
- </div>
- </div>
- </div>
Yana ba da ƙayyadaddun ƙayyadadden faɗin gama gari (da zaɓin amsa) tare da buƙatu kawai <div class="container">
.
- <jiki>
- <div class = "kwantena" >
- ...
- </div>
- </ jiki>
Ƙirƙirar ruwa, shafi mai shafi biyu tare da <div class="container-fluid">
-mai girma don aikace-aikace da takardu.
- <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>
Kunna CSS mai amsawa a cikin aikinku ta haɗa madaidaicin alamar meta da ƙarin salo a cikin <head>
takaddun ku. Idan kun haɗa Bootstrap daga shafin Customize, kuna buƙatar haɗa alamar meta kawai.
- <meta name = "viewport" abun ciki = "nisa = nisa-na'ura, sikelin farko=1.0" >
- <link href = "kadara/css/bootstrap-responsive.css" rel = "stylesheet" >
A kula!Bootstrap baya haɗa da fasalulluka masu amsa ta tsohuwa a wannan lokacin saboda ba komai yana buƙatar amsawa ba. Maimakon ƙarfafa masu haɓakawa don cire wannan fasalin, muna ganin zai fi dacewa mu kunna shi yadda ake buƙata.
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 |
---|---|---|---|
Babban nuni | 1200px da sama | 70px ku | 30px ku |
Default | 980px kuma sama | 60px ku | 20px ku |
Allunan hoto | 768px da sama | 42px ku | 20px ku |
Wayoyi zuwa kwamfutar hannu | 767px da ƙasa | ginshiƙan ruwa, babu tsayayyen faɗin | |
Wayoyi | 480px da ƙasa | ginshiƙan ruwa, babu tsayayyen faɗin |
- /* Babban Desktop */
- @media ( min - nisa : 1200px ) { ... }
- /* Hoton kwamfutar hannu zuwa wuri mai faɗi da tebur */
- @media ( min - nisa : 768px ) da ( max - nisa : 979px ) { ... }
- /* Wayar shimfidar wuri zuwa kwamfutar hannu mai hoto */
- @media ( max - nisa : 767px ) { ... }
- /* Wayoyin yanayi da ƙasa */
- @media ( max - nisa : 480px ) { ... }
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. A ƙasa akwai tebur na azuzuwan da ake da su da tasirinsu akan shimfidar tambayar kafofin watsa labarai da aka bayar (lakabi ta na'ura). Ana iya samun su a cikin responsive.less
.
Class | Wayoyi767px da ƙasa | Allunan979px zuwa 768px | KwamfutociDefault |
---|---|---|---|
.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 |
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. Kada a yi amfani da kayan aiki masu amsawa tare da tebur, kuma don haka ba a tallafawa.
Maimaita girman burauzarku ko lodi akan na'urori daban-daban don gwada azuzuwan da ke sama.
Koren cak yana 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.