Kupu Whakataki
Me timata ki a Bootstrap, te anga tino rongonui o te ao mo te hanga i nga pae aro, waea-tuatahi, me te jsDelivr me te wharangi timatanga tauira.
Te tiimata tere
Kei te titiro ki te taapiri tere a Bootstrap ki to kaupapa? Whakamahia te jsDelivr, he CDN puna tuwhera kore utu. Ma te whakamahi i te kaiwhakahaere kete me tango ranei i nga konae puna? Haere ki te whaarangi tango .
CSS
Tārua-whakapirihia te pepa kāhua <link>
ki roto i a koe <head>
i mua i era atu momo rau kāhua hei uta i a maatau CSS.
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
JS
Ko te nuinga o a maatau waahanga e hiahia ana ki te whakamahi i te JavaScript hei mahi. Ko te mea motuhake, me rapu taatau ake taputapu JavaScript me te Popper . Tuhia tetahi o nga mea e whai ake nei <script>
ki te pito o to wharangi, i mua tonu i te tohu kati </body>
, kia taea ai.
Paihere
Whakaurua ia Bootstrap JavaScript mono me te whakawhirinaki ki tetahi o a maatau paihere e rua. E rua bootstrap.bundle.js
me bootstrap.bundle.min.js
te whakauru Popper mo o maatau taputapu me nga pouvers. Mo etahi atu korero mo nga mea kei roto i te Bootstrap, tirohia ta maatau waahanga tirotiro .
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
Wehewehe
Mena ka whakatau koe ki te haere me te otinga tuhinga motuhake, me haere mai a Popper i te tuatahi (mehemea kei te whakamahi koe i nga aki taputapu, i nga popovers ranei), katahi a maatau taputapu JavaScript.
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
Kōwae
Mena kei te whakamahi koe <script type="module">
, tirohia to maatau whakamahi Bootstrap hei waahanga waahanga.
Waehanga
Kei te mohio ko nga waahanga e tino hiahia ana ki a maatau JavaScript me Popper? Paatohia te hono whakaatu wae i raro nei. Mena karekau koe e tino mohio mo te hanganga wharangi whanui, panui tonu mo tetahi tauira tauira tauira.
Whakaatuhia nga waahanga e hiahia ana ki te JavaScript
- Matohi mo te whakakore
- Patene mo te takahuri ahua me te pouakataki/mahinga reo irirangi
- Carousel mo nga whanonga kiriata katoa, mana whakahaere me nga tohu
- Tiango mo te takahuri i te tirohanga o te ihirangi
- Whakataka mo te whakaatu me te tuunga (me Popper ano hoki )
- Nga tauira mo te whakaatu, te tuunga, me te whanonga panuku
- Navbar mo te whakawhānui ake i to maatau Tiango mono ki te whakatinana i te whanonga aro
- Toasts mo te whakaatu me te whakakore
- Nga aki utauta me nga pouvers mo te whakaatu me te tuunga (me Popper ano hoki )
- Scrollspy mo te whanonga panuku me nga whakahou whakatere
tauira timata
Kia mohio koe ki te whakarite i o wharangi me nga paerewa hoahoa me te whanaketanga hou. Ko te tikanga ko te whakamahi i te momo tuhinga HTML5 me te whakauru i te tohu tohu meta tiro mo nga whanonga whakautu tika. Whakakotahitia katoatia kia penei te ahua o o wharangi:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
-->
</body>
</html>
Mo nga mahi ka whai ake, haere ki nga tuhinga Tahora , ki a maatau tauira whaimana ranei hei timata ki te whakatakoto i nga ihirangi me nga waahanga o to pae.
Te ao nui
Kei te whakamahi a Bootstrap i etahi momo ahua nui o te ao me nga tautuhinga e tika ana kia mohio koe i te wa e whakamahi ana, ko enei katoa he mea hanga noa ki te whakatikatika i nga momo tirotiro whakawhiti. Me ruku tatou.
HTML5 momo tuhinga
Me whakamahi a Bootstrap i te momo tuhinga HTML5. Ki te kore tenei, ka kite koe i etahi momo rorirori kaore i oti, engari ko te whakauru mai kia kaua e raru nui.
<!doctype html>
<html lang="en">
...
</html>
tūtohu meta urupare
I whakawhanakehia a Bootstrap mo te waea pūkoro i te tuatahi , he rautaki e arotau ai tatou i te waehere mo nga taputapu waea i te tuatahi, katahi ka piki ake nga waahanga e tika ana ma te whakamahi i nga patai pāpāho CSS. Hei whakarite kia tika te whakaputanga me te topa pa mo nga taputapu katoa, taapirihia te tohu meta tauranga tirohanga urupare ki to <head>
.
<meta name="viewport" content="width=device-width, initial-scale=1">
Ka taea e koe te kite i tetahi tauira o tenei mahi i roto i te tauira timata .
Pouaka-rahi
Mo te rahinga ngawari ake i roto i te CSS, ka huri tatou i te box-sizing
uara o te ao mai i content-box
te border-box
. Ma tenei ka padding
kore e pa ki te whanui rorohiko whakamutunga o tetahi huānga, engari ka raru pea ki etahi rorohiko-tuatoru penei i nga Mahere Google me te Miihini Rapu Ritenga a Google.
I nga wa onge ka hiahia koe ki te whakakore, whakamahia tetahi mea penei:
.selector-for-some-widget {
box-sizing: content-box;
}
Ma te snippet i runga ake nei, ko nga huānga kohanga—tae atu ki nga ihirangi i hangaia ma te— ::before
ka ::after
whakawhiwhia katoatia nga mea kua tohua box-sizing
mo tera .selector-for-some-widget
.
Ako atu mo te tauira pouaka me te rahi i CSS Tricks .
Whakahou ano
Mo te pai ake o te whakaputa whakawhiti-tirotiro, ka whakamahi matou i te Reboot ki te whakatika i nga maiorooro puta noa i nga kaitirotiro me nga taputapu i te wa e whakarato ana i nga taapiri whakaaro ki nga huānga HTML noa.
Hapori
Kia mau ki nga korero mo te whanaketanga o Bootstrap me te toro atu ki te hapori me enei rauemi awhina.
- Pānuihia me te ohauru ki te Blog Bootstrap Official .
- Kōrerorero me o hoa Bootstrappers i IRC. I runga i te
irc.libera.chat
tūmau, i te#bootstrap
hongere. - Implementation help may be found at Stack Overflow (tagged
bootstrap-5
). - Developers should use the keyword
bootstrap
on packages that modify or add to the functionality of Bootstrap when distributing through npm or similar delivery mechanisms for maximum discoverability.
You can also follow @getbootstrap on Twitter for the latest gossip and awesome music videos.