Source

Umi desplegable rehegua

Embohasa umi ñembojehe’a contextual rehegua ehechauka hag̃ua umi lista enlace ha hetave mba’e Bootstrap plugin desplegable reheve.

Tembiecharã

Umi desplegable ha’e toggleable, contextual superposición ojehechauka hag̃ua umi lista enlace rehegua ha hetave mba’e. Ojejapo hikuái interactivo pe JavaScript plugin desplegable Bootstrap oikeva’ekue ndive. Oñembohasa hikuái clic rupive, ndaha’éi ojehoverávo; péva peteî decisión intencional diseño reheguáva.

Umi desplegable oñemopu’ã peteĩ aranduka’i mbohapýha rehe, Popper.js , ome’ẽva ñemohenda dinámico ha jehechaukaha jehechakuaa. Emoĩ katuete popper.min.js Bootstrap JavaScript mboyve térã eipuru bootstrap.bundle.min.js/ bootstrap.bundle.jsoguerekóva Popper.js. Popper.js ndojeporúi oñemohenda hag̃ua umi desplegable navbar-pe jepémo noñeikotevẽiháicha ñemohenda dinámico.

Emopu’ãramo ore JavaScript ypykue guive, oikotevẽutil.js .

Accesibilidad rehegua

Pe WAI ARIA jeporupyre odefini peteĩ role="menu"widget añetegua , ha katu kóva haꞌehína específico umi menú aplicación-ichagua omoñepyrũva tembiapo térã tembiaporã. Umi menú ARIA rehegua ikatu oguereko umi mbaꞌe menú rehegua, umi menú vore vore rehegua, umi menú botón radio rehegua, umi aty radio botón rehegua ha umi submenú añoite.

Umi bootstrap mbaꞌekuaarã katu, ojejapo haꞌe hag̃ua genérico ha ojepurukuaa hag̃ua opaichagua situación ha estructura de marcado-pe. Techapyrã, ikatu ojejapo umi desplegable oguerekóva entrada adicional ha control formulario rehegua, haꞌeháicha umi tenda jeheka térã formulario jeikerã. Upévare, Bootstrap noha’arõi (ni omoĩ ijehegui) mba’eveichagua roleha aria-atributo oñeikotevẽva umi menú ARIA añeteguávape g̃uarã. Umi ohaíva oikeva’erã ijeheguiete ko’ã atributo específicovéva.

Ha katu, Bootstrap omoĩve pytyvõ oñemboguapýva hetavéva teclado menú ñembojoajurãme g̃uarã, haꞌeháicha ikatuha ojeguata .dropdown-itemelemento peteĩteĩva rupive ojeporúvo umi tecla cursor ha oñemboty menú ESCtecla reheve.

Tembiecharã

Embojere pe desplegable toggle (nde botón térã enlace) ha menú desplegable ryepýpe .dropdown, térã ambue elemento odeclaráva position: relative;. Umi dropdown ikatu oñemboguata <a>térã <button>elemento-kuéragui oñemohenda porãve hag̃ua ne remikotevẽ potencial.

Peteĩ botón añoite

Oimeraẽ peteĩva .btnikatu oñembohasa peteĩ toggle desplegable-pe peteĩ marca ñemoambue reheve. Ko’ápe ojehechauka mba’éichapa ikatu remoĩ omba’apo hag̃ua peteĩva umi <button>elemento ndive:

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown button
  </button>
  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
  </div>
</div>

Ha umi <a>elemento reheve:

<div class="dropdown">
  <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown link
  </a>

  <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
  </div>
</div>

Pe iporãvéva ha’e ikatuha rejapo kóva oimeraẽva botón variante reheve, avei:

<!-- Example single danger button -->
<div class="btn-group">
  <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Action
  </button>
  <div class="dropdown-menu">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
    <div class="dropdown-divider"></div>
    <a class="dropdown-item" href="#">Separated link</a>
  </div>
</div>

Botón ojedividi haguã

Upéicha avei, ejapo umi desplegable botón dividido orekóva prácticamente peteĩchagua marcado umi desplegable botón peteĩva ndive, ha katu oñembojoapývo .dropdown-toggle-splitespaciado hekopete caret desplegable jerére.

Jaipuru ko clase extra ñamboguejy hag̃ua horizontal paddingmokõive lado caret-pe 25% ha jaipeꞌa pe margin-leftthat’s oñembojoapýva umi botón desplegable regular-pe g̃uarã. Umi cambio extra omantene pe caret oñecentra pe botón split-pe ha ome’ẽ peteĩ área de golpe tamaño adecuadovéva pe botón principal ykére.

<!-- Example split danger button -->
<div class="btn-group">
  <button type="button" class="btn btn-danger">Action</button>
  <button type="button" class="btn btn-danger dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span class="sr-only">Toggle Dropdown</span>
  </button>
  <div class="dropdown-menu">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
    <div class="dropdown-divider"></div>
    <a class="dropdown-item" href="#">Separated link</a>
  </div>
</div>

Dimensionamiento rehegua

Umi botón desplegable ombaꞌapo umi botón opaichagua tuichakue ndive, umíva apytépe umi botón desplegable por defecto ha dividido.

<!-- Large button groups (default and split) -->
<div class="btn-group">
  <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Large button
  </button>
  <div class="dropdown-menu">
    ...
  </div>
</div>
<div class="btn-group">
  <button class="btn btn-secondary btn-lg" type="button">
    Large split button
  </button>
  <button type="button" class="btn btn-lg btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span class="sr-only">Toggle Dropdown</span>
  </button>
  <div class="dropdown-menu">
    ...
  </div>
</div>

<!-- Small button groups (default and split) -->
<div class="btn-group">
  <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Small button
  </button>
  <div class="dropdown-menu">
    ...
  </div>
</div>
<div class="btn-group">
  <button class="btn btn-secondary btn-sm" type="button">
    Small split button
  </button>
  <button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span class="sr-only">Toggle Dropdown</span>
  </button>
  <div class="dropdown-menu">
    ...
  </div>
</div>

Direcciones rehegua

Dropup rehegua

Emoñepyrũ umi menú desplegable elementokuéra ári emoĩvo .dropupelemento túvape.

<!-- Default dropup button -->
<div class="btn-group dropup">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropup
  </button>
  <div class="dropdown-menu">
    <!-- Dropdown menu links -->
  </div>
</div>

<!-- Split dropup button -->
<div class="btn-group dropup">
  <button type="button" class="btn btn-secondary">
    Split dropup
  </button>
  <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span class="sr-only">Toggle Dropdown</span>
  </button>
  <div class="dropdown-menu">
    <!-- Dropdown menu links -->
  </div>
</div>

Gota rehegua

Emoñepyrũ umi menú desplegable umi elemento akatúape emoĩvo .droprightelemento túvape.

<!-- Default dropright button -->
<div class="btn-group dropright">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropright
  </button>
  <div class="dropdown-menu">
    <!-- Dropdown menu links -->
  </div>
</div>

<!-- Split dropright button -->
<div class="btn-group dropright">
  <button type="button" class="btn btn-secondary">
    Split dropright
  </button>
  <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span class="sr-only">Toggle Dropright</span>
  </button>
  <div class="dropdown-menu">
    <!-- Dropdown menu links -->
  </div>
</div>

Gota rehegua

Emoñepyrũ umi menú desplegable umi elemento akatúape emoĩvo .dropleftelemento túvape.

<!-- Default dropleft button -->
<div class="btn-group dropleft">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropleft
  </button>
  <div class="dropdown-menu">
    <!-- Dropdown menu links -->
  </div>
</div>

<!-- Split dropleft button -->
<div class="btn-group">
  <div class="btn-group dropleft" role="group">
    <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      <span class="sr-only">Toggle Dropleft</span>
    </button>
    <div class="dropdown-menu">
      <!-- Dropdown menu links -->
    </div>
  </div>
  <button type="button" class="btn btn-secondary">
    Split dropleft
  </button>
</div>

Históricamente umi menú desplegable contenido ha’eva’erãkuri enlace, ha katu ndaha’evéima upéicha v4-pe. Koꞌág̃a ikatu reipuru opcionalmente umi <button>elemento nde desplegable-pe <a>s-nte rangue.

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown
  </button>
  <div class="dropdown-menu" aria-labelledby="dropdownMenu2">
    <button class="dropdown-item" type="button">Action</button>
    <button class="dropdown-item" type="button">Another action</button>
    <button class="dropdown-item" type="button">Something else here</button>
  </div>
</div>

Ikatu avei ejapo umi mba’e’oka ndaha’éiva interactivo .dropdown-item-text. Eñeñandu líbre emoĩve hag̃ua estilo CSS térã jehaipyre purupyrã jeporupyre reheve.

<div class="dropdown-menu">
  <span class="dropdown-item-text">Dropdown item text</span>
  <a class="dropdown-item" href="#">Action</a>
  <a class="dropdown-item" href="#">Another action</a>
  <a class="dropdown-item" href="#">Something else here</a>
</div>

Kyre'ỹ

Emoĩve .activeumi mbaꞌe oĩva pe desplegable-pe emoĩ hag̃ua estilo activo ramo .

<div class="dropdown-menu">
  <a class="dropdown-item" href="#">Regular link</a>
  <a class="dropdown-item active" href="#">Active link</a>
  <a class="dropdown-item" href="#">Another link</a>
</div>

Ñemonandi

Emoĩve .disabledumi mba’e’oka oĩva vore’ípe emoĩ hag̃ua estilo oñemboykéva ramo .

<div class="dropdown-menu">
  <a class="dropdown-item" href="#">Regular link</a>
  <a class="dropdown-item disabled" href="#">Disabled link</a>
  <a class="dropdown-item" href="#">Another link</a>
</div>

Por defecto, peteĩ menú desplegable oñemohenda ijeheguiete 100% yvate guive ha ituvakuéra akatúa gotyo. Emoĩ .dropdown-menu-rightpeteĩ .dropdown-menua derecha gotyo emohenda pe menú desplegable.

¡Akã yvate! Umi desplegable oñemohenda Popper.js rupive (ndahaꞌeiramo oĩ jave peteĩ navbar-pe).

<div class="btn-group">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Right-aligned menu
  </button>
  <div class="dropdown-menu dropdown-menu-right">
    <button class="dropdown-item" type="button">Action</button>
    <button class="dropdown-item" type="button">Another action</button>
    <button class="dropdown-item" type="button">Something else here</button>
  </div>
</div>

Akãrapu’ã

Emoĩ peteĩ iñakãrapuꞌa emoĩ hag̃ua etiqueta umi tembiaporã vore oimeraẽva menú desplegable-pe.

<div class="dropdown-menu">
  <h6 class="dropdown-header">Dropdown header</h6>
  <a class="dropdown-item" href="#">Action</a>
  <a class="dropdown-item" href="#">Another action</a>
</div>

Umi omboja’óva

Emboja’o umi aty umi elemento menú rehegua ojoajúva peteĩ divisor reheve.

<div class="dropdown-menu">
  <a class="dropdown-item" href="#">Action</a>
  <a class="dropdown-item" href="#">Another action</a>
  <a class="dropdown-item" href="#">Something else here</a>
  <div class="dropdown-divider"></div>
  <a class="dropdown-item" href="#">Separated link</a>
</div>

Maranduhai

Emoĩ oimeraẽva jehaipyre forma libre peteĩ menú desplegable ryepýpe jehaipyre reheve ha eipuru umi utilidad espaciado rehegua . Eñamindu’u oiméne reikotevẽtaha estilo de tamaño adicional ejoko hag̃ua menú ipekue.

<div class="dropdown-menu p-4 text-muted" style="max-width: 200px;">
  <p>
    Some example text that's free-flowing within the dropdown menu.
  </p>
  <p class="mb-0">
    And this is more example text.
  </p>
</div>

Umi Formulario rehegua

Emoĩ peteĩ formulario peteĩ menú desplegable ryepýpe, térã ejapo peteĩ menú desplegable-pe, ha eipuru umi utilidad margen térã relleno rehegua eme’ẽ hag̃ua chupe espacio negativo reikotevẽva.

<div class="dropdown-menu">
  <form class="px-4 py-3">
    <div class="form-group">
      <label for="exampleDropdownFormEmail1">Email address</label>
      <input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="[email protected]">
    </div>
    <div class="form-group">
      <label for="exampleDropdownFormPassword1">Password</label>
      <input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
    </div>
    <div class="form-check">
      <input type="checkbox" class="form-check-input" id="dropdownCheck">
      <label class="form-check-label" for="dropdownCheck">
        Remember me
      </label>
    </div>
    <button type="submit" class="btn btn-primary">Sign in</button>
  </form>
  <div class="dropdown-divider"></div>
  <a class="dropdown-item" href="#">New around here? Sign up</a>
  <a class="dropdown-item" href="#">Forgot password?</a>
</div>
<form class="dropdown-menu p-4">
  <div class="form-group">
    <label for="exampleDropdownFormEmail2">Email address</label>
    <input type="email" class="form-control" id="exampleDropdownFormEmail2" placeholder="[email protected]">
  </div>
  <div class="form-group">
    <label for="exampleDropdownFormPassword2">Password</label>
    <input type="password" class="form-control" id="exampleDropdownFormPassword2" placeholder="Password">
  </div>
  <div class="form-check">
    <input type="checkbox" class="form-check-input" id="dropdownCheck2">
    <label class="form-check-label" for="dropdownCheck2">
      Remember me
    </label>
  </div>
  <button type="submit" class="btn btn-primary">Sign in</button>
</form>

Eipuru data-offsettérã data-referenceemoambue hag̃ua moõpa oĩ pe desplegable.

<div class="d-flex">
  <div class="dropdown mr-1">
    <button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuOffset" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-offset="10,20">
      Offset
    </button>
    <div class="dropdown-menu" aria-labelledby="dropdownMenuOffset">
      <a class="dropdown-item" href="#">Action</a>
      <a class="dropdown-item" href="#">Another action</a>
      <a class="dropdown-item" href="#">Something else here</a>
    </div>
  </div>
  <div class="btn-group">
    <button type="button" class="btn btn-secondary">Reference</button>
    <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" id="dropdownMenuReference" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-reference="parent">
      <span class="sr-only">Toggle Dropdown</span>
    </button>
    <div class="dropdown-menu" aria-labelledby="dropdownMenuReference">
      <a class="dropdown-item" href="#">Action</a>
      <a class="dropdown-item" href="#">Another action</a>
      <a class="dropdown-item" href="#">Something else here</a>
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" href="#">Separated link</a>
    </div>
  </div>
</div>

Jeporu rehegua

Atributo de datos térã JavaScript rupive, pe plugin desplegable omoambue contenido kañymby (menú desplegable) ombohasávo .showclase elemento lista tuvakuéra rehegua. Pe data-toggle="dropdown"atributo ojejerovia oñemboty hag̃ua menú desplegable peteĩ aplicación nivel-pe, upévare iporã reipuru meme hag̃ua.

Umi tembipuru oñembohapéva táctil-pe, ojepeꞌa peteĩ desplegable oñembojoapy ( $.noop) mouseovermboguatahára nandi umi <body>elemento memby pyaꞌetevape. Ko hack admitidamente feo oñeikotevëva omba'apo haguã peteî quirk iOS' evento delegación , ambue mba'épe ojokóta peteî tap oimehápe okápe desplegable omoñepyrüva código ombotýva desplegable. Oñemboty rire pe desplegable, mouseoverojeipe’a ko’ã manipulador vacío adicional.

Umi atributo de datos rupive

Emoĩ data-toggle="dropdown"peteĩ enlace térã botón-pe emoambue hag̃ua peteĩ desplegable.

<div class="dropdown">
  <button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown trigger
  </button>
  <div class="dropdown-menu" aria-labelledby="dLabel">
    ...
  </div>
</div>

JavaScript rupive

Ehenói umi desplegable JavaScript rupive:

$('.dropdown-toggle').dropdown()
data-toggle="dropdown"oñeikotevẽ gueteri

Taha’e ha’éva ehenóiva ne desplegable JavaScript rupive térã upéva rangue eipuru data-api, data-toggle="dropdown"oñeikotevẽ akóinte oĩ presente pe desplegable elemento desencadenante-pe.

Opciones rehegua

Umi opción ikatu oñembohasa atributo de datos térã JavaScript rupive. Umi atributo dato rehegua, emoĩ opción réra data-, -peguáicha data-offset="".

Téra Hesegua Upevakuére Techaukaha
desplazamiento rehegua papapy | cadena rehegua | hembiapo 0 rehegua Desplazamiento pe desplegable rehegua relativo pe meta orekóva rehe. Ojeikuaave hag̃ua ehecha Popper.js offset docs .
jere booleano rehegua teete Eheja Dropdown ojere oikóramo peteĩ superposición elemento referencia rehegua. Ojeikuaave hag̃ua ehecha Popper.js flip docs .
límite rehegua cadena rehegua | mba'e rehegua 'desplazamientoTúva'. Límite restricción de desbordamiento rehegua menú desplegable rehegua. Omoneĩ umi mbaꞌekuaarã 'viewport', 'window', 'scrollParent', térã peteĩ HTMLElement ñembohekopyrã (JavaScript añoite). Ojeikuaave hag̃ua ehecha Popper.js kuatiahaipyre preventOverflow .
kuaukarã cadena rehegua | mba'e rehegua 'toggle' rehegua. Elemento de referencia menú desplegable rehegua. Omoneĩ umi mbaꞌekuaarã 'toggle', 'parent', térã peteĩ HTMLElement ñembohekopyrã. Ojeikuaave hag̃ua ehecha Popper.js referenceObject docs .
techaukahára 'dinámico' rehegua. Por defecto, jaipuru Popper.js ñemohenda dinámico-pe g̃uarã. Embogue ko mba’e static.

Eñamindu’u boundaryoñemboguapy jave oimeraẽ mba’ekuaarã ambuévape ndaha’éiva , ojeporu 'scrollParent'estilo mba’e’oka rehe.position: static.dropdown

Método-kuéra rehegua

Tapereko Techaukaha
$().dropdown('toggle') Ombohasa menú desplegable peteĩ navbar térã navegación ficha oñemeꞌevaꞌekue rehegua.
$().dropdown('update') Ombopyahu peteĩ elemento ñemboguejyha ñemohenda.
$().dropdown('dispose') Ohundi peteĩ elemento desplegable.

Umi mba’e oikóva

Opaite mbaꞌe ojehúva desplegable oñembopu .dropdown-menu's elemento túva rehe ha oguereko peteĩ relatedTargetmbaꞌekuaarã, ivalór haꞌehína elemento anclaje oñembohasáva. hide.bs.dropdownha hidden.bs.dropdownumi mbaꞌe ojehúva oguereko peteĩ clickEventmbaꞌekuaarã (pe mbaꞌe ojehúva ypykue tipo haꞌe jave añoite click) oguerekóva peteĩ Objeto Evento rehegua pe mbaꞌe ojehúva clic-pe g̃uarã.

Jeguerohyha Techaukaha
show.bs.dropdown Ko mbaꞌe ojehúva oñembopu pyaꞌe oñehenói jave método instancia ohechaukáva.
shown.bs.dropdown Ko mba’e ojehúva oñembogue ojejapo rire ojehecha hag̃ua puruhárape (oha’arõta umi CSS jehaipyre, oñembotývo).
hide.bs.dropdown Ko mbaꞌe ojehúva oñembogue pyaꞌe oñehenói rire pe método instancia omokañyvaꞌekue.
hidden.bs.dropdown Ko mba’e ojehúva oñembogue oñemokañypa rire pe desplegable puruháragui (oha’arõta CSS jehaipyre, oñembotývo).
$('#myDropdown').on('show.bs.dropdown', function () {
  // do something…
})