Jya ku bintu nyamukuru Jya kuri docs
in English

Ibikoresho

Inyandiko n'ingero zo kongeramo ibikoresho bya Bootstrap byabigenewe hamwe na CSS na JavaScript ukoresheje CSS3 kuri animasiyo na data-bs-ibiranga kubika izina ryaho.

Incamake

Ibintu ugomba kumenya mugihe ukoresheje plugin ya tooltip:

  • Ibikoresho byifashisha isomero ryishyaka rya 3 Popper kugirango ihagarare. Ugomba gushyiramo popper.min.js mbere ya bootstrap.js cyangwa gukoresha bootstrap.bundle.min.js/ bootstrap.bundle.jsirimo Popper kugirango ibikoresho bikore!
  • Ibikoresho ni opt-in kubwimpamvu zikorwa, ugomba rero kubitangiza wenyine .
  • Ibikoresho bifite imitwe ya zeru-ndende ntibigaragara.
  • Kugaragaza container: 'body'kugirango wirinde gutanga ibibazo mubice byinshi bigoye (nkitsinda ryacu ryinjiza, amatsinda ya buto, nibindi).
  • Gukurura ibikoresho byibikoresho byihishe ntabwo bizakora.
  • Ibikoresho .disabledcyangwa disabledibintu bigomba gukururwa kubintu bipfunyika.
  • Iyo iturutse kuri hyperlinks ikurikirana imirongo myinshi, ibikoresho bizaba hagati. Koresha white-space: nowrap;kuri <a>s kugirango wirinde iyi myitwarire.
  • Ibikoresho bigomba guhishwa mbere yuko ibintu bihuye bivanwa muri DOM.
  • Ibikoresho birashobora gukururwa dukesha ikintu kiri imbere mu gicucu DOM.
Mburabuzi, iki gice gikoresha ibikoresho byubatswe mu isuku, bikuraho ibintu byose bya HTML bitemewe. Reba igice cyisuku mubisobanuro byacu bya JavaScript kugirango ubone ibisobanuro birambuye.
Ingaruka ya animasiyo yibi bice biterwa prefers-reduced-motionnibibazo byitangazamakuru. Reba igice cyagabanijwe cyicyiciro cyibisobanuro byacu .

Wabonye ibyo byose? Nibyiza, reka turebe uko bakorana ningero zimwe.

Urugero: Gushoboza ibikoresho ahantu hose

Uburyo bumwe bwo gutangiza ibikoresho byose kurupapuro byaba ari uguhitamo data-bs-togglekubiranga:

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

Ingero

Hisha hejuru yibi bikurikira kugirango urebe ibikoresho:

Umwanya wanditse kugirango werekane umurongo uhuza hamwe nibikoresho. Ubu ni uwuzuza gusa, nta mwicanyi. Ibirimo byashyizwe hano gusa kugirango twigane ahari inyandiko nyayo . Kandi ibyo byose kugirango gusa nguhe igitekerezo cyukuntu ibikoresho byakoreshwa mugihe byakoreshejwe mubihe byukuri. Twizere rero ko ubu wabonye uburyo ibi bikoresho byihuza bishobora gukora mubikorwa, iyo ubikoresheje kurubuga rwawe cyangwa umushinga wawe.

Hisha hejuru ya buto hepfo kugirango urebe ibyerekezo bine byerekana: hejuru, iburyo, hepfo, n'ibumoso. Icyerekezo kirimo indorerwamo mugihe ukoresheje Bootstrap muri 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>

Hamwe na HTML yihariye yongeyeho:

<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>

Hamwe na SVG:

Sass

Ibihinduka

$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;

Ikoreshwa

Ibikoresho bya plugin bitanga ibikubiyemo nibiranga kubisabwa, kandi kubisanzwe byerekana ibikoresho nyuma yibintu byabo.

Koresha igikoresho ukoresheje JavaScript:

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

Umwanya wibikoresho ugerageza guhita uhinduka mugihe kontineri yababyeyi ifite overflow: autocyangwa overflow: scrollnkiyacu .table-responsive, ariko iracyakomeza imyanya yumwimerere. Kugira ngo iki kibazo gikemuke, shiraho boundaryamahitamo (kuri flip modifier ukoresheje popperConfigamahitamo) kuri HTMLElement iyariyo yose kugirango urengere agaciro gasanzwe, 'clippingParents'nka document.body:

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

Markup

Ikimenyetso gisabwa kubikoresho ni dataikiranga gusa no titlekuri element ya HTML wifuza kugira igikoresho. Ikimenyetso cyakozwe mubikoresho byoroshye biroroshye, nubwo bisaba umwanya (kubisanzwe, byashyizweho topna plugin).

Gukora ibikoresho bikora kuri clavier hamwe nabafasha gukoresha ikoranabuhanga

Ugomba kongeramo gusa ibikoresho byibikoresho bya HTML bisanzwe bisanzwe bya clavier-byibanda kandi bigakorana (nkumuhuza cyangwa kugenzura imiterere). Nubwo ibintu bya HTML uko bishakiye (nka <span>s) bishobora gukorwa byibandwaho mukongeramo tabindex="0"ikiranga, ibi bizongeramo ibishoboka birakaze kandi bitesha umutwe tab ihagarara kubintu bidakorana kubakoresha clavier, kandi tekinoroji ifasha muri iki gihe ntabwo itangaza ibikoresho muri ibi bihe. Ikigeretse kuri ibyo, ntukishingikirize gusa hovernkigitera ibikoresho byawe, kuko ibi bizatuma ibikoresho byawe bidashoboka gukurura abakoresha clavier.

<!-- 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>

Ibintu byahagaritswe

Ibintu bifite disabledikiranga ntabwo bikorana, bivuze ko abakoresha badashobora kwibanda, kugendagenda, cyangwa kubikanda kugirango batere igikoresho (cyangwa popover). Nkumurimo wakazi, uzashaka gukurura ibikoresho biva mubipfunyika <div>cyangwa <span>, nibyiza byakozwe na clavier-yibanze ukoresheje 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>

Amahitamo

Amahitamo arashobora kunyuzwa kumurongo wamakuru cyangwa JavaScript. Kubiranga Ibyatanzwe, Ongeraho Ihitamo Izina Kuri data-bs-, Nka Muri data-bs-animation="". Witondere guhindura ubwoko bwurubanza rwamazina kuva kuri camelCase kuri kebab-urubanza mugihe utambutsa amahitamo ukoresheje ibiranga amakuru. Kurugero, aho gukoresha data-bs-customClass="beautifier", koresha data-bs-custom-class="beautifier".

Menya ko kubwimpamvu zumutekano the sanitize,, sanitizeFnhamwe allowListnamahitamo ntashobora gutangwa ukoresheje ibiranga amakuru.
Izina Andika Mburabuzi Ibisobanuro
animation boolean true Koresha CSS igenda ihinduka kubikoresho
container umugozi | ikintu | ibinyoma false

Ongeraho ibikoresho byibikoresho runaka. Urugero : container: 'body'. Ihitamo ni ingirakamaro cyane cyane kuburyo rigufasha gushyira ibikoresho byifashishwa mugutembera kwinyandiko hafi yikintu gikurura - bizarinda igikoresho cyo kureremba kure yikintu gikurura mugihe idirishya rinini.

delay umubare | ikintu 0

Gutinda kwerekana no guhisha ibikoresho (ms) - ntibikoreshwa muburyo bwintoki

Niba umubare watanzwe, gutinda gukoreshwa byombi guhisha / kwerekana

Imiterere yibintu ni:delay: { "show": 500, "hide": 100 }

html boolean false

Emerera HTML mubikoresho.

Niba ari ukuri, ibirango bya HTML mubikoresho byerekana titlebizerekanwa mubikoresho. Niba ari ibinyoma, innerTextumutungo uzakoreshwa mugushyiramo ibiri muri DOM.

Koresha inyandiko niba uhangayikishijwe n'ibitero bya XSS.

placement umugozi | imikorere 'top'

Nigute ushobora gushira ibikoresho - auto | hejuru | munsi | ibumoso | iburyo.
Iyo autobisobanuwe neza, bizahindura icyerekezo cyibikoresho.

Iyo imikorere ikoreshwa mukumenya aho ishyirwa, byitwa hamwe na tooltip DOM node nkibisobanuro byayo byambere hamwe na elementing DOM node nkibya kabiri. Imirongo thisyashizwe kumurongo wibikoresho.

selector umugozi | ibinyoma false Niba uwatoranije atanzwe, ibikoresho byibikoresho bizahabwa intego zerekanwe. Mu myitozo, ibi bikoreshwa mugukoresha ibikoresho byongeweho imbaraga za DOM ( jQuery.oninkunga). Reba ibi nurugero rwamakuru .
template umugozi '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'

Shingiro HTML yo gukoresha mugihe uremye ibikoresho.

Ibikoresho bya titlebikoresho bizaterwa muri .tooltip-inner.

.tooltip-arrowByahindutse umwambi wibikoresho.

Ikintu cyo hanze gifunga ibintu kigomba kugira urwego .tooltipna role="tooltip".

title umugozi | ikintu | imikorere ''

Mburabuzi Umutwe Agaciro niba titleIkiranga kidahari.

Niba imikorere yatanzwe, izahamagarwa hamwe thisnibisobanuro byayo byashyizwe kumurongo ibikoresho bifatanye.

trigger umugozi 'hover focus'

Uburyo ibikoresho byifashishwa - kanda | hover | kwibanda | imfashanyigisho. Urashobora gutsinda imbarutso nyinshi; kubatandukanya n'umwanya.

'manual'yerekana ko igikoresho kizaterwa na porogaramu binyuze muri .show(), .hide()nuburyo .toggle(); agaciro ntigashobora guhuzwa nizindi mbarutso.

'hover'ku giti cyayo bizavamo ibikoresho bidashobora gukururwa hifashishijwe clavier, kandi bigomba gukoreshwa gusa niba ubundi buryo bwo gutanga amakuru amwe kubakoresha clavier ahari.

fallbackPlacements array ['top', 'right', 'bottom', 'left'] Sobanura ibyasubiwemo mugutanga urutonde rwibibanza biri murwego (ukurikije ibyifuzo). Kubindi bisobanuro reba imyitwarire ya Popper
boundary umugozi | element 'clippingParents' Kurenga imipaka imipaka yibikoresho (ikoreshwa gusa kuri popper yo gukumiraOverflow modifier). Mburabuzi ni 'clippingParents'kandi irashobora kwakira HTMLElement yerekanwe (ukoresheje JavaScript gusa). Kubindi bisobanuro reba popper's detectOverflow docs .
customClass umugozi | imikorere ''

Ongeraho amasomo kubikoresho iyo byerekanwe. Menya ko aya masomo azongerwaho hiyongereyeho ibyiciro byose byerekanwe mubishusho. Ongeraho ibyiciro byinshi, ubitandukanye numwanya : 'class-1 class-2'.

Urashobora kandi gutambutsa imikorere igomba gusubiza umurongo umwe urimo amazina yinyongera.

sanitize boolean true Gushoboza cyangwa guhagarika isuku. Niba ukora 'template'kandi 'title'amahitamo azagira isuku. Reba igice cyisuku mubyangombwa byacu bya JavaScript .
allowList ikintu Agaciro gasanzwe Ikintu kirimo ibiranga byemewe na tagi
sanitizeFn null | imikorere null Hano urashobora gutanga imikorere yawe yisuku. Ibi birashobora kuba ingirakamaro niba uhisemo gukoresha isomero ryabigenewe kugirango ukore isuku.
offset array | umugozi | imikorere [0, 0]

Offset ya tooltip ugereranije nintego yayo. Urashobora gutambutsa umurongo muri data ibiranga hamwe na koma yatandukanijwe indangagaciro nka:data-bs-offset="10,20"

Iyo imikorere ikoreshwa mukumenya offset, yitwa hamwe nikintu kirimo popper yashyizwe, icyerekezo, hamwe na popper ikosora nkibitekerezo byayo byambere. Ikintu gikurura DOM node yatambutse nkimpaka ya kabiri. Igikorwa kigomba gusubiza umurongo hamwe nimibare ibiri : .[skidding, distance]

Kubindi bisobanuro reba kuri popper ya offset .

popperConfig null | ikintu | imikorere null

Guhindura Bootstrap isanzwe ya Popper config, reba iboneza rya Popper .

Iyo imikorere ikoreshwa mugukora iboneza rya Popper, byitwa hamwe nikintu kirimo Bootstrap idasanzwe ya Popper. Iragufasha gukoresha no guhuza ibisanzwe hamwe nuburyo bwawe bwite. Imikorere igomba gusubiza ibintu byabugenewe kuri Popper.

Ibiranga amakuru kubikoresho byihariye

Amahitamo kubikoresho byihariye arashobora gutomorwa mugukoresha ibiranga amakuru, nkuko byasobanuwe haruguru.

Gukoresha imikorere hamwepopperConfig

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

Uburyo

Uburyo butajegajega ninzibacyuho

Inzira zose za API ntizihuza kandi zitangira inzibacyuho . Basubira kumuhamagara mugihe inzibacyuho itangiye ariko itararangira . Mubyongeyeho, uburyo bwo guhamagarira ibice byinzibacyuho bizirengagizwa .

Reba inyandiko zacu za JavaScript kubindi bisobanuro .

kwerekana

Yerekana igikoresho cyibikoresho. Garuka kumuhamagara mbere yuko ibikoresho byerekanwe (ni ukuvuga mbere yuko shown.bs.tooltipibyabaye biba). Ibi bifatwa nk "intoki" itera ibikoresho. Ibikoresho bifite imitwe ya zeru-ndende ntibigaragara.

tooltip.show()

kwihisha

Hisha igikoresho cyibikoresho. Garuka kumuhamagara mbere yigikoresho cyihishe mubyukuri (nukuvuga mbere yuko hidden.bs.tooltipibyabaye biba). Ibi bifatwa nk "intoki" itera ibikoresho.

tooltip.hide()

guhinduranya

Kuzuza ibikoresho by'ibikoresho. Garuka kumuhamagara mbere yuko ibikoresho byerekanwe cyangwa byihishe (ni ukuvuga mbere yuko ibyabaye shown.bs.tooltipcyangwa hidden.bs.tooltipibyabaye bibaho). Ibi bifatwa nk "intoki" itera ibikoresho.

tooltip.toggle()

guta

Hisha kandi isenya igikoresho cyibikoresho (Kuraho amakuru yabitswe kubintu bya DOM). Ibikoresho bifashisha intumwa (zakozwe hakoreshejwe amahitamoselector ) ntibishobora gusenywa kugiti cyawe kubintu bikomokaho .

tooltip.dispose()

Gushoboza

Itanga igikoresho cyibikoresho ubushobozi bwo kwerekanwa. Ibikoresho bifasha byanze bikunze.

tooltip.enable()

guhagarika

Kuraho ubushobozi bwibikoresho byerekanwa. Igikoresho kizashobora gusa kwerekanwa niba cyongeye gukora.

tooltip.disable()

Guhindura

Kuzamura ubushobozi bwibikoresho byerekanwa cyangwa byihishe.

tooltip.toggleEnabled()

kuvugurura

Kuvugurura umwanya wibikoresho bya element.

tooltip.update()

Kubona

Uburyo buhagaze butuma ubona ibikoresho byerekana urugero bifitanye isano na DOM

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

Kubona

Uburyo buhamye bugufasha kubona urugero rwibikoresho bifitanye isano na DOM, cyangwa gukora bundi bushya mugihe bitatangijwe

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

Ibyabaye

Ubwoko bwibyabaye Ibisobanuro
show.bs.tooltip Ibirori birasa ako kanya mugihe showurugero rwitwa.
shown.bs.tooltip Ibi birori birukanwa mugihe ibikoresho byakorewe kugaragara kubakoresha (bizategereza ko CSS ihinduka).
hide.bs.tooltip Ibi birori birahita bisohoka mugihe uburyo hidebwurugero bwahamagawe.
hidden.bs.tooltip Ibirori birukanwa mugihe ibikoresho byarangije guhishwa kubakoresha (bizategereza ko CSS ihinduka).
inserted.bs.tooltip Ibirori birukanwa nyuma show.bs.tooltipyibyabaye mugihe ibikoresho byifashishijwe byongewe kuri DOM.
var myTooltipEl = document.getElementById('myTooltip')
var tooltip = new bootstrap.Tooltip(myTooltipEl)

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

tooltip.hide()