Batoli ya bisaleli
Mikanda mpe bandakisa mpo na kobakisa bisaleli ya Bootstrap ya moto ye moko na CSS mpe JavaScript na kosalelaka CSS3 mpo na ba animations mpe ba data-bs-attributs mpo na kobomba titre ya esika.
Botali ya mozindo
Makambo oyo osengeli koyeba ntango ozali kosalela plugin ya tooltip:
- Tooltips etie motema na bibliothèque ya 3ème partie Popper pona positionnement. Esengeli otia popper.min.js liboso ya bootstrap.js to osalela
bootstrap.bundle.min.js
/bootstrap.bundle.js
oyo ezali na Popper mpo ete ba toli ya bisaleli esalaka! - Tooltips ezali opt-in mpo na ba raisons ya performance, yango wana esengeli o initialiser yango yo moko .
- Ba toli ya bisaleli oyo ezali na mitó ya makambo ya bolai zéro emonisami ata mokolo moko te.
- Boyebisa
container: 'body'
pona ko éviter ba problèmes ya rendu na ba composants plus complexes (lokola ba groupes na biso ya entrée, ba groupes ya boutons, etc). - Ko déclencher ba toli ya bisaleli na ba éléments oyo ebombami ekosala te.
- Ba toli ya bisaleli mpo na
.disabled
todisabled
ba éléments esengeli e déclenché na élément ya enveloppe. - Ntango ebandisami uta na ba hyperliens oyo epanzani na milɔngɔ mingi, ba toli ya bisaleli ekozala na katikati. Salelá
white-space: nowrap;
na s na yo<a>
mpo na koboya ezaleli oyo. - Esengeli kobomba ba toli ya bisaleli yambo ya kolongola ba éléments na yango oyo ekokani na yango na DOM.
- Ba conseils d'outils ekoki ko déclenché grâce na élément moko na kati ya DOM ya ombre.
prefers-reduced-motion
requête ya média. Tala
eteni ya mouvement réduit ya mikanda na biso ya accessibilité .
Ozwi nyonso wana? Monene, totala ndenge basalaka na mwa bandakisa.
Ndakisa: Salá ete batoli ya bisaleli ezala bisika nyonso
Lolenge moko ya ko initialiser ba toli nionso ya bisaleli na lokasa moko ekozala ya kopona yango na data-bs-toggle
attribut na yango:
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
Bandakisa
Botia maboko na ba liens oyo ezali awa na se mpo na komona ba toli ya bisaleli:
Mokanda ya esika mpo na kolakisa mwa ba liens ya kati na ba toli ya bisaleli. Oyo eza sikoyo kaka filler, killer te. Contenu oyo batie awa kaka pona ko imiter présence ya texte ya solo . Mpe nyonso wana kaka mpo na kopesa yo likanisi ya ndenge oyo batoli ya bisaleli ekozala ntango basaleli yango na makambo ya solosolo. Donc espérons que omoni sikoyo ndenge nini ba conseils d’outils oyo na ba liens ekoki kosala na pratique, mbala moko osaleli yango na site to projet na yo moko .
Tyá lobɔkɔ likoló ya ba boutons oyo ezali awa na nse mpo na komona malako minei ya malako ya bisaleli: likoló, na lobɔkɔ ya mobali, na nse mpe na lobɔkɔ ya mwasi. Ba direction ezali mirroré tango ozali kosalela Bootstrap na 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>
Mpe na HTML ya momeseno oyo ebakisami:
<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>
Na SVG moko:
Sass oyo azali
Ba variables oyo ezali
$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;
Kosalela yango
Plugin ya tooltip ebimisaka contenus mpe marquage na demande, mpe par défaut etie ba tooltip sima ya élément ya déclencheur na bango.
Déclenchez tooltip na nzela ya JavaScript:
var exampleEl = document.getElementById('example')
var tooltip = new bootstrap.Tooltip(exampleEl, options)
Débordement auto
mpescroll
Position ya Tooltip emekaka kobongola automatiquement tango conteneur ya moboti ezali to overflow: auto
lokola overflow: scroll
ya biso .table-responsive
, kasi ebatelaka kaka positionnement ya placement ya ebandeli. Mpo na kosilisa yango, tia boundary
option (mpo na modificateur ya flip kosalela popperConfig
option) na HTMLElement nionso mpo na ko superposer valeur par défaut, 'clippingParents'
, lokola document.body
:
var exampleEl = document.getElementById('example')
var tooltip = new bootstrap.Tooltip(exampleEl, {
boundary: document.body // or document.querySelector('#boundary')
})
Kosala bilembo
Marquage oyo esengeli mpo na tooltip ezali kaka data
attribut mpe title
na élément HTML olingi kozala na tooltip. Marquage oyo esalemi ya tooltip ezali plutôt simple, atako esengaka position (par défaut, etiamaki na top
na plugin).
Kosala ete ba toli ya bisaleli esalaka mpo na basaleli ya klaviatware mpe ya tekiniki ya kosunga
Esengeli kaka kobakisa ba conseils ya bisaleli na ba éléments HTML oyo na bonkoko ekoki ko focuser na clavier mpe interactif (lokola ba liens to ba contrôles ya formulaire). Atako ba éléments HTML arbitraires (lokola <span>
s) ekoki kosalama focusable na kobakisa tabindex="0"
attribut, yango ekobakisa ba arrêts ya onglet potentiellement dérangeant mpe confusion na ba éléments non interactifs mpo na ba usagers ya clavier, mpe ba technologies mingi ya assistance na tango oyo esakolaka tooltip te na situation oyo. En plus, ko se fier kaka te hover
comme déclencheur ya tooltip na yo, po yango ekosala que ba tolips na yo ezala impossible ya ko déclencher pona ba usagers ya 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>
Ba éléments oyo ekangami
Ba éléments oyo ezali na disabled
attribut ezali interactif te, elingi koloba ba usagers bakoki te ko focuser, ko hover, to ko cliquer yango pona ko déclencher tooltip (to popover). Lokola likambo ya kosilisa yango, okolinga ko déclencher tooltip uta na enveloppe <div>
to <span>
, malamu esalemi na clavier-focusable na kosalelaka 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>
Makambo oyo okoki kopona
Ba options ekoki koleka na nzela ya ba attributs ya ba données to JavaScript. Mpo na ba attributs ya ba données, bakisa kombo ya option na data-bs-
, lokola na data-bs-animation=""
. Sala makasi obongola lolenge ya cas ya kombo ya option uta camelCase na kebab-case tango ozali koleka ba options na nzela ya ba attributs ya ba données. Na ndakisa, na esika ya kosalela data-bs-customClass="beautifier"
, salelá data-bs-custom-class="beautifier"
.
sanitize
,
sanitizeFn
, mpe
allowList
ba options ekoki kopesama te na kosalelaka ba attributs ya ba données.
Nkombo | Lolenge | Mbeba | Ndimbola |
---|---|---|---|
animation |
boolean | true |
Salelá transition ya fade ya CSS na tooltip |
container |
molongo ya molongo | élément | lokuta | false |
Ebakisi toli ya bisaleli na eloko moko ya sikisiki. Ndakisa: |
delay |
motango | moto ya likambo | 0 |
Retard ya kolakisa pe kobomba tooltip (ms) - etali te lolenge ya déclencheur manuel Soki nimero moko epesami, retard esalemi na nyonso mibale kobomba/lakisa Bokeli ya eloko ezali: |
html |
boolean | false |
Tika HTML na kati ya tooltip. Soki ezali solo, ba balises HTML na tooltip's Salelá makomi soki ozali komitungisa mpo na ba attaques ya XSS. |
placement |
molongo ya molongo | mosala | 'top' |
Ndenge nini ko positionner tooltip - auto | likolo ya likolo | na nse | na gauche | malamu. Tango fonction esalelami pona koyeba placement, ebengami na node DOM ya tooltip lokola argument na yango ya liboso mpe node DOM ya élément déclencheur lokola ya mibale na yango. Contexte |
selector |
molongo ya molongo | lokuta | false |
Soki moponi epesami, biloko ya tooltip ekopesama na ba cibles oyo elakisami. Na pratique, yango esalelamaka pona pe kosalela ba toli ya bisaleli na ba éléments DOM oyo ebakisami dynamiquement ( jQuery.on soutien). Talá oyo mpe ndakisa moko oyo ezali kopesa makambo mingi . |
template |
shene | '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' |
Base HTML ya kosalela tango ya kosala tooltip. Ba tooltip's
Elemento ya enveloppe ya libanda esengeli kozala na |
title |
molongo ya molongo | élément | mosala | '' |
Valeur ya titre par défaut soki Soki fonction epesami, ekobenga yango na |
trigger |
shene | 'hover focus' |
Ndenge nini tooltip ebandi - finá | kosala hover | focus | mokanda. Okoki koleka ba déclencheur ebele; kokabola bango na esika moko.
|
fallbackPlacements |
array | ['top', 'right', 'bottom', 'left'] |
Limbola ba placements ya fallback na kopesaka liste ya ba placements na array (na ordre ya préférence). Mpo na koyeba makambo mingi tala ba docs ya bizaleli ya Popper |
boundary |
molongo ya molongo | eloko | 'clippingParents' |
Frontière ya contrainte ya débordement ya tooltip (etali kaka na modificateur ya preventOverflow ya Popper). Na ndenge ya libela ezali 'clippingParents' mpe ekoki kondima référence HTMLElement (na nzela ya JavaScript kaka). Mpo na koyeba makambo mingi tala Docs ya detectOverflow ya Popper . |
customClass |
molongo ya molongo | mosala | '' |
Bakisa ba classes na tooltip tango elakisami. Yeba ete ba classes oyo ekobakisama en plus ya ba classes nionso oyo elakisami na modèle. Mpo na kobakisa bakelasi mingi, kabola yango na bisika: Okoki mpe koleka fonction oyo esengeli kozongisa molongo moko oyo ezali na ba kombo ya kelasi ya kobakisa. |
sanitize |
boolean | true |
Activer to désactiver sanitisation. Soki activé 'template' pe 'title' ba options ekozala sanitisé. Tala eteni ya sanitizer na mikanda na biso ya JavaScript . |
allowList |
moto ya likambo | Valeur ya défaut | Objet oyo ezali na ba attributs na ba balises oyo epesami nzela |
sanitizeFn |
null | mosala | null |
Awa okoki ko fournir fonction ya sanitize na yo moko. Yango ekoki kozala na ntina soki olingi kosalela bibliotɛkɛ oyo ebongisami mpo na kosala bopɛto. |
offset |
array ya | molongo ya molongo | mosala | [0, 0] |
Offset ya tooltip par rapport na cible na yango. Okoki koleka molongo na ba attributs ya ba données na ba valeurs oyo ekabwani na virgule lokola: Tango fonction esalelami pona koyeba offset, ebengamaka na objet oyo ezali na placement ya popper, référence, na ba rects ya popper lokola argument na yango ya liboso. Node DOM ya élément déclencheur eleki lokola argument ya mibale. Fonction esengeli kozongisa array oyo ezali na ba nombres mibale: . Mpo na koyeba makambo mingi tala Docs ya offset ya Popper . |
popperConfig |
null | eloko | mosala | null |
Mpo na kobongola configuration ya Popper ya liboso ya Bootstrap, tala configuration ya Popper . Tango fonction moko esalelami pona kosala configuration ya Popper, ebengami na objet oyo ezali na configuration ya Popper par défaut ya Bootstrap. Esalisaka yo osalela mpe osangisa oyo ya liboso na configuration na yo moko. Fonction esengeli kozongisa objet ya configuration pona Popper. |
Ba attributs ya ba données pona ba toli ya bisaleli moko moko
Ba options pona ba toli ya bisaleli moko moko ekoki na ndenge mosusu kozala précisé na nzela ya bosaleli ya ba attributs ya ba données, ndenge elimbolami likolo.
Kosalela fonction napopperConfig
var tooltip = new bootstrap.Tooltip(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Ba méthodes ya kosala
Ba méthodes asynchrones na ba transitions
Ba méthodes nionso ya API ezali asynchrone mpe ebandi transition . Bazongaka epai ya moto oyo abengi ntango kaka mbongwana ebandi kasi liboso ete esila . En plus, appel ya méthode na composante ya transition ekozala ignorée .
Tala mikanda na biso ya JavaScript mpo na koyeba makambo mosusu .
kolakisa
Ezali kobimisa tooltip ya élément moko. Ezongi na mobengi yambo ete tooltip elakisama mpenza (elingi koloba liboso ete shown.bs.tooltip
likambo esalema). Yango etalelami lokola déclenchement “manuel” ya tooltip. Ba toli ya bisaleli oyo ezali na mitó ya makambo ya bolai zéro emonisami ata mokolo moko te.
tooltip.show()
kobombana
Ebombaka tooltip ya élément moko. Ezongi na mobengi yambo ete tooltip ebombama mpenza (elingi koloba liboso ete hidden.bs.tooltip
likambo esalema). Yango etalelami lokola déclenchement “manuel” ya tooltip.
tooltip.hide()
kobongola makambo
Ezali kobongola toggle ya tooltip ya élément moko. Ezongi na mobengi yambo ete toli ya bisaleli elakisama to ebombama mpenza (elingi koloba liboso ete likambo shown.bs.tooltip
to hidden.bs.tooltip
esalema). Yango etalelami lokola déclenchement “manuel” ya tooltip.
tooltip.toggle()
kobwaka yango
Ebombaka mpe ebebisaka tooltip ya élément moko (Elongolaka ba données oyo ebombami na élément DOM). Ba toli ya bisaleli oyo esalela délégation (oyo esalemi na kosalelaka option selector
) ekoki kobebisama moko moko te na ba éléments déclencheur descendant.
tooltip.dispose()
kopesa nzela
Epesi tooltip ya élément moko makoki ya kolakisa. Ba toli ya bisaleli efungolami na ndenge ya libela.
tooltip.enable()
kolongola
Elongolaka makoki mpo na tooltip ya eleman moko elakisama. Likanisi ya bisaleli ekozala na makoki ya kolakisa kaka soki efungolami lisusu.
tooltip.disable()
toggleEzali na mosala
Ezali kobongola makoki mpo ete tooltip ya eleman moko elakisama to ebombama.
tooltip.toggleEnabled()
ya sika
Ezali kosala mikolo oyo position ya tooltip ya élément moko.
tooltip.update()
kozwaInstance
Méthode statique oyo e permettre yo ozua instance ya tooltip associé na élément DOM
var exampleTriggerEl = document.getElementById('example')
var tooltip = bootstrap.Tooltip.getInstance(exampleTriggerEl) // Returns a Bootstrap tooltip instance
kozwaToKosalaInstance
Méthode statique oyo e permettre yo ozua instance ya tooltip associé na élément DOM, to kosala ya sika au cas où ebandaki ko initialiser te
var exampleTriggerEl = document.getElementById('example')
var tooltip = bootstrap.Tooltip.getOrCreateInstance(exampleTriggerEl) // Returns a Bootstrap tooltip instance
Makambo oyo esalemaki
Lolenge ya likambo | Ndimbola |
---|---|
show.bs.tooltip |
Evenement oyo ezo beta mbala moko tango show méthode ya instance ebengami. |
shown.bs.tooltip |
Evenement oyo ezo beta tango tooltip esalemi komonana na mosaleli (ekozela ba transitions ya CSS esila). |
hide.bs.tooltip |
Evenement oyo ezo beta mbala moko tango hide méthode ya instance ebengami. |
hidden.bs.tooltip |
Evenement oyo ezo beta tango tooltip esili kobombama na mosaleli (ekozela ba transitions ya CSS esila). |
inserted.bs.tooltip |
Evenement oyo ezo beta sima ya show.bs.tooltip événement tango modèle ya tooltip ebakisami na DOM. |
var myTooltipEl = document.getElementById('myTooltip')
var tooltip = new bootstrap.Tooltip(myTooltipEl)
myTooltipEl.addEventListener('hidden.bs.tooltip', function () {
// do something...
})
tooltip.hide()