Source

Taw qhia

Pib nrog Bootstrap, lub ntiaj teb nrov tshaj plaws lub moj khaum rau lub tsev teb, mobile-thawj qhov chaw, nrog jsDelivr thiab ib tug template pib nplooj ntawv.

Pib nrawm

Nrhiav kom nrawm ntxiv Bootstrap rau koj qhov project? Siv jsDelivr, muab pub dawb los ntawm cov neeg ntawm jsDelivr. Siv tus thawj tswj pob lossis xav tau rub tawm cov ntaub ntawv los? Mus rau nplooj ntawv downloads.

CSS

Luam-muab cov stylesheet <link>rau hauv koj <head>ua ntej tag nrho lwm cov stylesheets thauj peb CSS.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

JS

Ntau ntawm peb cov khoom yuav tsum tau siv JavaScript los ua haujlwm. Tshwj xeeb, lawv xav tau jQuery , Popper.js , thiab peb tus kheej JavaScript plugins. Muab cov nram qab no <script>nyob ze rau qhov kawg ntawm koj nplooj ntawv, txoj cai ua ntej kaw </body>tag, kom pab tau lawv. jQuery yuav tsum tuaj ua ntej, tom qab ntawd Popper.js, thiab tom qab ntawd peb JavaScript plugins.

Peb siv jQuery's slim tsim , tab sis tag nrho version kuj tau txais kev txhawb nqa.

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

Xav paub tias cov khoom twg qhia meej yuav tsum tau jQuery, peb JS, thiab Popper.js? Nyem qhov qhia cov khoom txuas hauv qab no. Yog tias koj tsis paub meej txog cov qauv nplooj ntawv dav dav, nyeem ntawv rau ib qho piv txwv nplooj ntawv template.

Peb bootstrap.bundle.jsthiab bootstrap.bundle.min.jssuav nrog Popper , tab sis tsis yog jQuery . Yog xav paub ntxiv txog dab tsi muaj nyob rau hauv Bootstrap, thov mus saib peb cov ntsiab lus seem.

Qhia cov khoom uas xav tau JavaScript
  • Kev ceeb toom rau kev tso tseg
  • Nyees khawm rau toggling xeev thiab checkbox / xov tooj cua functionality
  • Carousel rau txhua tus cwj pwm swb, tswj, thiab ntsuas
  • Kaw rau toggling pom cov ntsiab lus
  • Dropdowns rau displaying thiab positioning (tseem yuav tsum tau Popper.js )
  • Modals rau displaying, positioning, thiab scroll cwj pwm
  • Navbar rau txuas ntxiv peb Collapse plugin los siv tus cwj pwm teb
  • Cov lus qhia thiab popovers rau kev nthuav qhia thiab tso (tseem xav tau Popper.js )
  • Scrollspy rau scroll cwj pwm thiab navigation hloov tshiab

Pib template

Nco ntsoov kom koj cov nplooj ntawv teeb tsa nrog cov qauv tsim tshiab thiab kev tsim kho tshiab. Qhov ntawd txhais tau hais tias siv HTML5 doctype thiab suav nrog qhov pom qhov pom meta tag rau kev coj tus cwj pwm zoo. Muab tag nrho ua ke thiab koj cov nplooj ntawv yuav tsum zoo li no:

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  </body>
</html>

Qhov ntawd yog txhua yam koj xav tau rau tag nrho cov nplooj ntawv xav tau. Mus saib cov Layout docs lossis peb cov piv txwv tseem ceeb los pib tso tawm koj lub vev xaib cov ntsiab lus thiab cov khoom siv.

Lub ntiaj teb tseem ceeb

Bootstrap ntiav ib tug puv tes ntawm cov qauv thoob ntiaj teb tseem ceeb thiab cov chaw uas koj yuav tsum paub txog thaum siv nws, tag nrho cov uas yuav luag tshwj xeeb rau kev ua kom zoo ntawm tus ntoo khaub lig browser style. Cia peb dhia dej.

HTML5 doctype

Bootstrap xav kom siv HTML5 doctype. Yog tsis muaj nws, koj yuav pom qee qhov kev lom zem tsis tiav, tab sis suav nrog nws yuav tsum tsis txhob ua rau muaj kev ntxhov siab ntau.

<!doctype html>
<html lang="en">
  ...
</html>

Responsive meta tag

Bootstrap yog tsim mobile ua ntej , lub tswv yim nyob rau hauv uas peb optimize code rau mobile pab kiag li lawm ua ntej thiab ces scale up Cheebtsam raws li tsim nyog siv CSS media queries. Txhawm rau kom ua tiav qhov tsim nyog thiab kov zooming rau txhua yam khoom siv, ntxiv cov lus teb pom pom meta tag rau koj <head>.

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

Koj tuaj yeem pom ib qho piv txwv ntawm qhov no hauv kev nqis tes ua hauv qhov pib template .

Box-sizing

Rau qhov yooj yim dua qhov loj me hauv CSS, peb hloov tus box-sizingnqi thoob ntiaj teb los ntawm content-boxmus rau border-box. Qhov no ua kom paddingtsis muaj kev cuam tshuam rau qhov kawg suav dav ntawm ib lub caij, tab sis nws tuaj yeem ua teeb meem nrog qee tus neeg sab nrauv software xws li Google Maps thiab Google Custom Search Engine.

Nyob rau lub sijhawm tsis tshua muaj koj yuav tsum override nws, siv qee yam zoo li hauv qab no:

.selector-for-some-widget {
  box-sizing: content-box;
}

Nrog cov snippet saum toj no, nested ntsiab-nrog rau generated cov ntsiab lus ntawm ::beforethiab ::after-yuav tag nrho cov qub txeeg qub teg box-sizingrau qhov ntawd .selector-for-some-widget.

Kawm ntxiv txog lub thawv qauv thiab qhov loj me ntawm CSS Tricks .

Rov pib dua

Rau kev txhim kho tus ntoo khaub lig-browser rendering, peb siv Reboot los kho qhov tsis sib xws ntawm cov browsers thiab cov khoom siv thaum muab cov kev xav me ntsis rov pib dua rau cov ntsiab lus HTML.

Zej Zog

Nyob twj ywm rau hnub tim ntawm kev txhim kho Bootstrap thiab ncav cuag lub zej zog nrog cov peev txheej pab tau.

  • Ua raws @getbootstrap ntawm Twitter .
  • Nyeem thiab sau npe mus rau Lub Tsev Haujlwm Bootstrap Blog .
  • Tham nrog cov phooj ywg Bootstrappers hauv IRC. Nyob rau hauv lub irc.freenode.netserver, nyob rau hauv lub ##bootstrapchannel.
  • Kev pab cuam tuaj yeem pom ntawm Stack Overflow (tagged bootstrap-4).
  • Cov neeg tsim khoom yuav tsum siv lo lus tseem ceeb bootstrapntawm cov pob khoom uas hloov kho lossis ntxiv rau kev ua haujlwm ntawm Bootstrap thaum faib los ntawm npm lossis cov txheej txheem xa khoom zoo sib xws rau kev tshawb pom ntau tshaj plaws.

Koj tseem tuaj yeem ua raws @getbootstrap ntawm Twitter rau cov lus xaiv tshiab thiab cov yeeb yaj kiab txaus ntshai.