Fa'asolo ile anotusi autu Fa'asolo ile fa'ata'ita'iga o fa'amatalaga
in English

Mea faigaluega

Faʻamaumauga ma faʻataʻitaʻiga mo le faʻaopoopoina o mea faigaluega Bootstrap masani ma le CSS ma le JavaScript e faʻaaoga ai le CSS3 mo faʻafiafiaga ma faʻamatalaga-bs-uiga mo le teuina o ulutala faʻapitonuʻu.

Vaaiga lautele

Mea e tatau ona iloa pe a faʻaaogaina le meafaigaluega faʻapipiʻi:

  • Mea faigaluega fa'alagolago ile faletusi lona tolu Popper mo le fa'atulagaina. E tatau ona e aofia ai popper.min.js i luma o le bootstrap.js poʻo le faʻaoga bootstrap.bundle.min.js/ bootstrap.bundle.jso loʻo i ai Popper ina ia mafai ai ona faʻaoga meafaigaluega!
  • O mea faigaluega e filifili i totonu mo mafuaʻaga o faʻatinoga, o lea e tatau ai ona e amataina oe lava ia .
  • E le fa'aalia lava ni mea faigaluega e leai ni fa'ailoga umi.
  • Fa'ama'oti container: 'body'e 'alofia ai le fa'atupuina o fa'afitauli i vaega e sili atu ona lavelave (pei o tatou vaega fa'aoga, vaega fa'amau, ma isi).
  • E le aoga le fa'aosoina o mea faigaluega i elemene natia.
  • O mea faigaluega mo .disabledpo'o disabledelemene e tatau ona fa'aoso i luga o se elemene afifi.
  • A fa'aoso mai hyperlinks e tele laina, o le a fa'atotonugalemu mea faigaluega. Fa'aoga white-space: nowrap;i lou <a>s e aloese ai mai lenei amio.
  • E tatau ona natia mea faigaluega a'o le'i aveesea a latou elemene tutusa mai le DOM.
  • Tooltips e mafai ona faʻaosoina faʻafetai i se elemene i totonu o se ata lafoia DOM.
Ona o le faaletonu, e fa'aogaina e lenei vaega le fa'amama fa'ainitaneti, lea e aveese ai so'o se elemene HTML e le fa'atagaina manino. Va'ai le vaega sanitizer i la matou pepa JavaScript mo nisi fa'amatalaga.
O le aafiaga o le animation o lenei vaega e fa'alagolago i le su'esu'ega a le prefers-reduced-motionaufaasālalau. Va'ai le vaega fa'aitiitiga fa'aitiitiga oa matou pepa fa'aoga avanoa .

E maua uma na mea? Lelei, se'i o tatou va'ai pe fa'apefea ona latou galulue fa'atasi ma ni fa'ata'ita'iga.

Fa'ata'ita'iga: Fa'aaga mea faigaluega i so'o se mea

O se tasi o auala e amata ai meafaigaluega uma i luga o se itulau o le filifilia lea i latou data-bs-toggleuiga:

var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
  return new bootstrap.Tooltip(tooltipTriggerEl)
})

Faataitaiga

Fa'apa i luga o so'oga o lo'o i lalo e va'ai i mea faigaluega:

Fa'amatalaga o lo'o tu'u iai e fa'aalia ai nisi o feso'ota'iga fa'atasi ma mea faigaluega. O lea ua na'o le fa'atumu, leai se fasioti tagata. O mea o lo'o tu'uina iinei e fa'atusa ai le iai o tusitusiga moni . Ma o na mea uma e naʻo le tuʻuina atu ia te oe o se manatu pe faʻapefea ona foliga meafaigaluega pe a faʻaaogaina i tulaga moni o le lalolagi. Fa'amoemoe la ua e va'ai nei pe fa'apefea ona galue nei mea faigaluega i luga o so'otaga i le fa'atinoga, pe a e fa'aogaina i luga o lau lava saite po'o le poloketi.

Fa'ae'e i luga o fa'amau i lalo e va'ai ai fa'atonuga meafaigaluega e fa: luga, taumatau, lalo, ma le agavale. E fa'aali fa'atonuga pe a fa'aogaina le Bootstrap ile RTL.

<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top">
  Tooltip on top
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right" title="Tooltip on right">
  Tooltip on right
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Tooltip on bottom">
  Tooltip on bottom
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" title="Tooltip on left">
  Tooltip on left
</button>

Ma faʻatasi ai ma le HTML masani faʻaopoopo:

<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
  Tooltip with HTML
</button>

Faatasi ai ma se SVG:

Sass

Fuafuaga

$tooltip-font-size:                 $font-size-sm;
$tooltip-max-width:                 200px;
$tooltip-color:                     $white;
$tooltip-bg:                        $black;
$tooltip-border-radius:             $border-radius;
$tooltip-opacity:                   .9;
$tooltip-padding-y:                 $spacer * .25;
$tooltip-padding-x:                 $spacer * .5;
$tooltip-margin:                    0;

$tooltip-arrow-width:               .8rem;
$tooltip-arrow-height:              .4rem;
$tooltip-arrow-color:               $tooltip-bg;

Fa'aoga

O le tooltip plugin e fa'atupuina ai mea ma fa'ailoga pe a mana'omia, ma e le mafai ona tu'u meafaigaluega pe a mae'a a latou elemene fa'aoso.

Fa'aoso le mea faigaluega e ala ile JavaScript:

var exampleEl = document.getElementById('example')
var tooltip = new bootstrap.Tooltip(exampleEl, options)
Taumasua automascroll

Ole tulaga ole Tooltip e taumafai e sui otometi pe a iai pe fiafia ile atigipusa matua ile matou , ae o lo'o tumau pea le tulaga o le tu'uga muamua. Ina ia foia lenei mea, seti le filifiliga (mo le faʻaoga suiga e faʻaaoga ai le filifiliga) i soʻo se HTMLElement e faʻamalo ai le tau le aoga, , e pei o le :overflow: autooverflow: scroll.table-responsiveboundarypopperConfig'clippingParents'document.body

var exampleEl = document.getElementById('example')
var tooltip = new bootstrap.Tooltip(exampleEl, {
  boundary: document.body // or document.querySelector('#boundary')
})

Fa'ailoga

O le fa'ailoga mana'omia mo se meafaigaluega e na'o se datauiga ma titleluga ole elemene HTML e te mana'o e maua se meafaigaluega. O le faʻailoga faʻatupuina o se meafaigaluega e faigofie tele, e ui lava e manaʻomia se tulaga (e ala i le faaletonu, seti i tople plugin).

O le fa'aogaina o meafaigaluega e aoga mo keyboard ma fa'aoga tekonolosi fesoasoani

E tatau ona e fa'aopoopo na'o mea faigaluega i elemene HTML e masani ona fa'aogaina le keyboard ma fegalegaleai (pei o feso'ota'iga po'o fa'atonuga). E ui lava e mafai ona faʻaogaina elemene HTML (e pei o <span>le s) e ala i le faʻaopoopoina o le tabindex="0"uiga, o le a faʻaopoopoina faʻalavelave faʻalavelave ma fenumiai taofi i luga o elemene e le o fesoʻotaʻi mo tagata faʻaoga keyboard, ma o le tele o tekinolosi fesoasoani i le taimi nei e le o faʻasalalau le meafaigaluega i lenei tulaga. E le gata i lea, aua le fa'alagolago na'o hoverle fa'aosoina o lau meafaigaluega, aua o le a le mafai ai e au meafaigaluega ona fa'aosoina mo tagata fa'aoga keyboard.

<!-- HTML to write -->
<a href="#" data-bs-toggle="tooltip" title="Some tooltip text!">Hover over me</a>

<!-- Generated markup by the plugin -->
<div class="tooltip bs-tooltip-top" role="tooltip">
  <div class="tooltip-arrow"></div>
  <div class="tooltip-inner">
    Some tooltip text!
  </div>
</div>

Elemene le atoatoa

O elemene e iai le disableduiga e le fegalegaleai, o lona uiga e le mafai e tagata faʻaoga ona taulaʻi, faʻafefe, pe kiliki i latou e faʻaosoina ai se meafaigaluega (poʻo le popover). I le avea ai o se fofo, e te manaʻo e faʻaosoina le meafaigaluega mai se afifi <div>poʻo <span>, faʻaoga lelei le keyboard-faʻaoga e faʻaaoga ai le tabindex="0".

<span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" title="Disabled tooltip">
  <button class="btn btn-primary" type="button" disabled>Disabled button</button>
</span>

Filifiliga

O filifiliga e mafai ona pasia e ala i faʻamatalaga uiga poʻo le JavaScript. Mo fa'amatalaga uiga, fa'aopoopo le igoa filifiliga i le data-bs-, pei o le data-bs-animation="". Ia mautinoa e sui le ituaiga mataupu o le igoa filifiliga mai le camelCase i le kebab-case pe a pasia filifiliga e ala i faʻamatalaga uiga. Mo se faʻataʻitaʻiga, nai lo le faʻaaogaina data-bs-customClass="beautifier", faʻaaoga data-bs-custom-class="beautifier".

Manatua e le mafai ona tu'uina atu mo le saogalemu le sanitize, sanitizeFn, ma allowListfilifiliga e fa'aoga ai uiga fa'amaumauga.
Igoa Ituaiga Fa'atonu Fa'amatalaga
animation boolean true Fa'aoga se suiga e mou atu CSS i le mea faigaluega
container manoa | elemene | pepelo false

Fa'apipi'i le mea faigaluega i se elemene fa'apitoa. Faataitaiga: container: 'body'. O lenei filifiliga e sili ona aoga ona e mafai ai e oe ona tuʻu le mea faigaluega i le tafe o le pepa i tafatafa o le elemene faʻaoso - lea o le a taofia ai le meafaigaluega mai le opeopea ese mai le elemene faʻaoso i le taimi o le suiga o le faamalama.

delay numera | mea faitino 0

Fa'atuai ona fa'aali ma nana le mea faigaluega (ms) - e le fa'atatau ile ituaiga fa'aoso tusi

Afai e tu'uina atu se numera, fa'atuai e fa'aoga i natia/fa'aali uma

O le fausaga o mea faitino o le:delay: { "show": 500, "hide": 100 }

html boolean false

Fa'ataga le HTML i le mea faigaluega.

Afai e sa'o, o fa'ailoga HTML o lo'o i totonu o meafaigaluega o le titlea fa'aalia i le meafaigaluega. Afai e sese, innerTexto le a fa'aoga meatotino e fa'aofi ai mea i totonu ole DOM.

Fa'aoga tusitusiga pe a e popole i osofa'iga a le XSS.

placement manoa | galuega faatino 'top'

Fa'afefea ona fa'atulaga le mea faigaluega - ta'avale | pito i luga | lalo | agavale | tauagavale.
A autofa'amaoti mai, o le a fa'amaninoina le fa'atonuga o meafaigaluega.

Pe a faʻaaogaina se galuega e fuafua ai le tuʻuina, e taʻua i le tooltip DOM node e fai ma ana finauga muamua ma le elemene DOM node lona lua. O thislo'o fa'atulaga le tala i le fa'ata'ita'iga meafaigaluega.

selector manoa | pepelo false Afai e tu'uina atu se tagata filifilia, o mea fa'aoga meafaigaluega o le a tu'uina atu i fa'amoemoega fa'apitoa. I le faʻataʻitaʻiga, o loʻo faʻaaogaina e faʻaoga ai foi meafaigaluega e faʻaopoopo atili ai elemene DOM ( jQuery.onlagolago). Vaʻai i lenei mea ma se faʻataʻitaʻiga faʻamatalaga .
template manoa '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'

Fa'avae HTML e fa'aoga pe a fai le mea faigaluega.

O mea faigaluega o le titlea tui i totonu o le .tooltip-inner.

.tooltip-arrowo le a avea ma aū a le meafaigaluega.

O le elemene afifi pito i fafo e tatau ona i ai le .tooltipvasega ma role="tooltip".

title manoa | elemene | galuega faatino ''

Fa'aigoa fa'aigoa tau pe afai titlee le o iai le uiga.

Afai e tu'uina atu se galuega, o le a vala'au ma lona thisfa'asinomaga seti i le elemene o lo'o fa'apipi'i i ai le meafaigaluega.

trigger manoa 'hover focus'

E fa'afefea ona fa'aosoina meafaigaluega - kiliki | lele | taula'i | tusi lesona. E mafai ona e pasia le tele o fa'aoso; tuueseese ma se avanoa.

'manual'o lo'o fa'ailoa mai ai o le a fa'aosoina fa'apolokalame le fa'atonuga meafaigaluega e ala i le .show(), .hide()ma .toggle()metotia; e le mafai ona tu'ufa'atasia lenei tau ma so'o se isi fa'aoso.

'hover'na o ia lava o le a maua ai meafaigaluega e le mafai ona faʻaosoina e ala i le piano, ma e tatau ona faʻaaogaina pe afai o loʻo i ai isi auala mo le faʻasalalauina o faʻamatalaga tutusa mo tagata faʻaoga keyboard.

fallbackPlacements fa'asologa ['top', 'right', 'bottom', 'left'] Fa'amatala tulaga fa'afo'i i tua e ala i le tu'uina atu o se lisi o mea fa'apipi'i i fa'asologa (i le fa'asologa o mea e fiafia i ai). Mo nisi fa'amatalaga va'ai ile Popper's behavior docs
boundary manoa | elemene 'clippingParents' Fa'agata tapula'a tuaoi o le mea faigaluega (fa'atatau i le Popper's preventOverflow modifier). E le mafai 'clippingParents'ona talia ma e mafai ona talia se HTMLElement reference (e ala i le JavaScript). Mo nisi faʻamatalaga vaʻai ile Popper's detectOverflow docs .
customClass manoa | galuega faatino ''

Fa'aopoopo vasega i le mea faigaluega pe a fa'aalia. Manatua o nei vasega o le a faʻaopoopoina i soʻo se vasega o loʻo faʻamaonia i le mamanu. Ina ia faaopoopo ni vasega se tele, tuueseese i avanoa: 'class-1 class-2'.

E mafai fo'i ona e pasia se galuega e tatau ona toe fa'afo'i se manoa e tasi e iai isi igoa o vasega.

sanitize boolean true Fa'amalo pe tape le fa'amama. Afai e fa'agaoioia 'template'ma 'title'filifiliga o le a fa'amama. Va'ai le vaega sanitizer i la matou pepa JavaScript .
allowList mea faitino Tau fa'aletonu Mea e iai uiga fa'atagaina ma fa'ailoga
sanitizeFn null | galuega faatino null O iinei e mafai ona e tu'uina atu lau lava galuega fa'amama. E mafai ona aoga pe afai e te mana'o e fa'aoga se faletusi fa'apitoa e fa'atino ai le fa'amama.
offset fa'asologa | manoa | galuega faatino [0, 0]

Fa'a'ese'ese ole mea faigaluega e fa'atatau ile fa'amoemoe. E mafai ona e pasiina se manoa i uiga fa'amaumauga ma fa'ailoga e vavae'ese koma e pei o:data-bs-offset="10,20"

A fa'aoga se galuega e fa'atatau ai le offset, e ta'ua i se mea o lo'o i ai le fa'apipi'i popper, le fa'asinomaga, ma le popper rects e fai ma ana finauga muamua. O le fa'aosoina elemene DOM node ua pasia e fai ma finauga lona lua. O le galuega e tatau ona toe faʻafoʻi se laina e lua numera: .[skidding, distance]

Mo nisi fa'amatalaga va'ai ile Popper's offset docs .

popperConfig null | mea | galuega faatino null

Ina ia suia le faʻaogaina o le Popper config a Bootstrap, vaʻai i le faatulagaga a Popper .

A faʻaaogaina se galuega e fai ai le Popper configuration, e valaʻau i se mea e aofia ai le faʻaogaina o le Popper configuration a le Bootstrap. E fesoasoani ia te oe e fa'aoga ma tu'ufa'atasia le mea e le mafai ona fai ma lau lava fa'atulagaga. Ole galuega e tatau ona toe faʻafoʻi se mea faʻatulagaina mo Popper.

Fa'amatalaga uiga mo meafaigaluega ta'itasi

O filifiliga mo meafaigaluega ta'ito'atasi e mafai ona fa'amaonia e ala i le fa'aogaina o uiga fa'amaumauga, e pei ona fa'amatalaina i luga.

Fa'aaogaina galuega fa'atasi mapopperConfig

var tooltip = new bootstrap.Tooltip(element, {
  popperConfig: function (defaultBsPopperConfig) {
    // var newPopperConfig = {...}
    // use defaultBsPopperConfig if needed...
    // return newPopperConfig
  }
})

Metotia

Metotia ma suiga e le tutusa

O metotia API uma e le fetaui ma amata se suiga . Latou te toe fo'i atu i le tagata telefoni i le taimi lava e amata ai le suiga ae le'i uma . E le gata i lea, o le a le amana'ia se auala e vala'au ai i se vaega o suiga .

Va'ai la matou pepa JavaScript mo nisi fa'amatalaga .

fa'aali

Fa'aalia le mea faigaluega o se elemene. Toe fo'i atu i le tagata vala'au a'o le'i fa'aalia moni mai le mea faigaluega (fa'atusa a'o le'i tupu le shown.bs.tooltipmea na tupu). O lenei mea ua manatu o se "manual" faʻaosoina o le meafaigaluega. E le fa'aalia lava ni mea faigaluega e leai ni fa'ailoga umi.

tooltip.show()

lalafi

Natia le mea faigaluega o se elemene. Toe fo'i atu i le tagata vala'au a'o le'i natia le mea faigaluega (fa'atusa a'o le'i tupu le hidden.bs.tooltipmea na tupu). O lenei mea ua manatu o se "manual" faʻaosoina o le meafaigaluega.

tooltip.hide()

fesuia'i

Su'e le pito meafaigaluega a se elemene. Toe fo'i i le tagata vala'au a'o le'i fa'aalia pe natia le mea faigaluega (fa'atusa a'o le'i tupu le shown.bs.tooltippo'o le hidden.bs.tooltipmea na tupu). O lenei mea ua manatu o se "manual" faʻaosoina o le meafaigaluega.

tooltip.toggle()

lafoa'i

Natia ma fa'aleagaina le mea faigaluega a le elemene (Ave'ese fa'amaumauga o lo'o teuina ile elemene DOM). Tooltips e fa'aogaina le tu'uina atu (lea e faia i le fa'aogaina o le selectorfilifiliga ) e le mafai ona fa'aumatia ta'ito'atasi i elemene fa'aoso tupuaga.

tooltip.dispose()

mafai

E tu'uina atu i se mea e fa'aoga meafaigaluega e mafai ona fa'aalia. E mafai ona fa'aogaina mea faigaluega.

tooltip.enable()

fa'aletonu

Aveese le agava'a mo se mea faigaluega e fa'aalia. Fa'atoa mafai ona fa'aalia le mea faigaluega pe a toe fa'aagaina.

tooltip.disable()

ToggleEnabled

Fa'afeso'ota'i le agava'a mo se mea faigaluega e fa'aalia pe natia.

tooltip.toggleEnabled()

fa'afouga

Fa'afou le tulaga o se mea faigaluega a le elemene.

tooltip.update()

getInstance

Metotia static lea e mafai ai e oe ona maua le faʻataʻitaʻiga meafaigaluega e fesoʻotaʻi ma se elemene DOM

var exampleTriggerEl = document.getElementById('example')
var tooltip = bootstrap.Tooltip.getInstance(exampleTriggerEl) // Returns a Bootstrap tooltip instance

getOrCreateInstance

Metotia static lea e mafai ai e oe ona maua le faʻataʻitaʻiga meafaigaluega e fesoʻotaʻi ma se elemene DOM, poʻo le fatuina o se mea fou i le tulaga e leʻi amataina.

var exampleTriggerEl = document.getElementById('example')
var tooltip = bootstrap.Tooltip.getOrCreateInstance(exampleTriggerEl) // Returns a Bootstrap tooltip instance

Mea na tutupu

Ituaiga mea na tupu Fa'amatalaga
show.bs.tooltip E mu vave lenei mea pe a showvala'au le auala fa'ata'ita'i.
shown.bs.tooltip O lenei mea na tupu e faʻamalo pe a faʻaalia le mea faigaluega i le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa).
hide.bs.tooltip O lenei mea na tupu e faʻamalo vave pe a hidevalaʻau le auala faʻataʻitaʻiga.
hidden.bs.tooltip O lenei mea na tupu e faʻamalo pe a maeʻa ona natia le meafaigaluega mai le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa).
inserted.bs.tooltip O lenei mea na tupu e faʻamalo pe a maeʻa le show.bs.tooltipmea na tupu ina ua faʻaopoopo le faʻataʻitaʻiga meafaigaluega i le DOM.
var myTooltipEl = document.getElementById('myTooltip')
var tooltip = new bootstrap.Tooltip(myTooltipEl)

myTooltipEl.addEventListener('hidden.bs.tooltip', function () {
  // do something...
})

tooltip.hide()