Как оно функционирует датируй - toggle bootstrap 4 в dropdown меню?

У меня хотят быть два dropdown меню в sidebar, но проблема состоит в том, что у меня появляются те же выборы в обоих:

<!doctype html>
<html lang="es" >
  <head>
<title>BASICO</title>
<!-- Required meta tags -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/ico" href="favicon.ico" />
<!-- Bootstrap CSS -->
   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

 <!-- Fontawesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous"/>

<!-- Bootstrap  JS-->
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

<!-- Include all compiled plugins (below), or include individual files as needed -->


<link rel="stylesheet" type="text/css" href="css/estilos.css" media="screen" />
  </head>
<div class="d-flex" id="wrapper">

<!-- Sidebar -->
<div class="bg-light border-right" id="sidebar-wrapper">
  <div class="sidebar-heading">OPCIONES</div>
  <div class="list-group list-group-flush">
    <a data-toggle="modal" data-target="#myModal" href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-search"></i><span  id="artmodal"> ARTICULO - F2</span>
  </a>

    <a data-toggle="modal" data-target="#miModals" href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-wrench"></i><span  id="serv"> SERVICIO - F7</span></a>
    <a  data-toggle="modal" data-target="#myModalCC" href="" class="list-group-item list-group-item-action bg-light"> <i  class="fas fa-list"></i><span  id="CC"> CUENTAS   - F4</span></a>
    <a href="#" class="list-group-item list-group-item-action bg-light"><i  class="fas fa-dollar-sign"></i><span  id="VENTA"> VENTA   -   F6</span></a>
      <a class="list-group-item list-group-item-action bg-light" href="#" id="navbarDropdowndatos" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-database"></i>
           DATOS
          </a>  <div class="dropdown-menu" aria-labelledby="navbarDropdowndatos">
   <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-user"></i><span  id="user">USUARIOS</span>
</a>
 <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-user"></i><span  id="cliente">CLIENTES</span>
</a>
 <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-list-alt"></i><span  id="art">ARTICULOS</span>
</a>
 <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-user"></i><span  id="prov">PROVEEDORES</span>
</a>
       
          </div>
 <a href="#" class="list-group-item list-group-item-action bg-light" id="navbarDropdowncaja" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-cash-register"></i><span  id="art2">CAJA</span>
</a> <div class="dropdown-menu" aria-labelledby="navbarDropdowncaja">
   <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-cash-register"></i><span  id="estado">ESTADO</span>
</a>
 <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-invoice-dollar"></i><span  id="cuentas">CUENTAS CORRIENTES</span>
</a>

       
          </div>
  </div>
</div>
<!-- /#sidebar-wrapper -->

<!-- Page Content -->
<div id="page-content-wrapper">

  <nav class="navbar navbar-expand-lg navbar-light bg-light border-bottom">
    <button class="btn btn-primary" id="menu-toggle"><i class="fas fa-sliders-h"></i></button>

    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto mt-2 mt-lg-0">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Dropdown
          </a>
          <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown2">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Something else here</a>
          </div>
        </li>
      </ul>
    </div>
  </nav>

  <div class="container-fluid">
    <h1 class="mt-4">Simple Sidebar</h1>
    <p>The starting state of the menu will appear collapsed on smaller screens, and will appear non-collapsed on larger screens. When toggled using the button below, the menu will change.</p>
    <p>Make sure to keep all page content within the <code>#page-content-wrapper</code>. The top navbar is optional, and just for demonstration. Just create an element with the <code>#menu-toggle</code> ID which will toggle the menu when clicked.</p>
  </div>
</div>
<!-- /#page-content-wrapper -->

  </div>
  <!-- /#wrapper -->

  <!-- Bootstrap core JavaScript -->


  <!-- Menu Toggle Script -->
  <script>
$("#menu-toggle").click(function(e) {
  e.preventDefault();
  $("#wrapper").toggleClass("toggled");
});
  </script>

</body>

</html>

А именно они ссылаются на тот же div выборов я предполагаю. Как я могу делать?, поскольку они будут видеть, есть отличные выборы у обоих divs.

0
задан 23.12.2019, 02:52
1 ответ

Проблема estГЎ в как снопы призыв к каждому из dropdown в list, я думаю, чем в этом случае, так как estГЎs используя bootstrap как основание, он может использовать тебя Ваших структур, чтобы создавать твой sidebar с dropdowns, так как очень простым способом ты можешь отвечать то, что уже у тебя есть, и ты гарантируешь себе, что funcionarГЎ совсем правильно без того, чтобы ты был должен помогать mГЎs cГіdigo. Я оставляю тебе пример, как он может оставаться внутри тебя cГіdigo, но lГіgicamente, не меняя стиля ему:

        $("#menu-toggle").click(function(e) {
          e.preventDefault();
          $("#wrapper").toggleClass("toggled");
        });
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <title>Document</title>
</head>

    <div class="d-flex" id="wrapper">

        <!-- Sidebar -->
        <div class="bg-light border-right" id="sidebar-wrapper">
          <div class="sidebar-heading">OPCIONES</div>
          <div class="list-group list-group-flush">
            <a data-toggle="modal" data-target="#myModal" href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-search"></i><span  id="artmodal"> ARTICULO - F2</span>
          </a>
        
            <a data-toggle="modal" data-target="#miModals" href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-wrench"></i><span  id="serv"> SERVICIO - F7</span></a>
            <a  data-toggle="modal" data-target="#myModalCC" href="" class="list-group-item list-group-item-action bg-light"> <i  class="fas fa-list"></i><span  id="CC"> CUENTAS   - F4</span></a>
            <a href="#" class="list-group-item list-group-item-action bg-light"><i  class="fas fa-dollar-sign"></i><span  id="VENTA"> VENTA   -   F6</span></a>
              <a class="list-group-item list-group-item-action bg-light" href="#" id="navbarDropdowndatos" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-database"></i>
                   DATOS
                  </a> 
                   <div class="dropdown-menu" aria-labelledby="navbarDropdowndatos">
           <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-user"></i><span  id="user">USUARIOS</span>
        </a>
         <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-user"></i><span  id="cliente">CLIENTES</span>
        </a>
         <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-list-alt"></i><span  id="art">ARTICULOS</span>
        </a>
         <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-user"></i><span  id="prov">PROVEEDORES</span>
        </a>
               
                  </div>
         <a href="#" class="list-group-item list-group-item-action bg-light" id="navbarDropdowncaja" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-cash-register"></i><span  id="art2">CAJA</span>
        </a> 
        
        <div class="dropdown-menu" aria-labelledby="navbarDropdowncaja">
           <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-cash-register"></i><span  id="estado">ESTADO</span>
        </a>
         <a href="" class="list-group-item list-group-item-action bg-light"><i class="fas fa-invoice-dollar"></i><span  id="cuentas">CUENTAS CORRIENTES</span>
        </a>
                  </div>

                  <!-- 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">
            <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>
      
      <!-- 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">
            <a class="dropdown-item" href="#">Action 2</a>
            <a class="dropdown-item" href="#">Another action 2</a>
            <a class="dropdown-item" href="#">Something else here 2</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link 2</a>
          </div>
      </div>
       
    </div>
          </div>

          
        <!-- /#sidebar-wrapper -->
        
        <!-- Page Content -->
        <div id="page-content-wrapper">
        
          <nav class="navbar navbar-expand-lg navbar-light bg-light border-bottom">
            <button class="btn btn-primary" id="menu-toggle"><i class="fas fa-sliders-h"></i></button>
        
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>
        
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
              <ul class="navbar-nav ml-auto mt-2 mt-lg-0">
                <li class="nav-item active">
                  <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">Link</a>
                </li>
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Dropdown
                  </a>
                  <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown2">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Something else here</a>
                  </div>
                </li>
              </ul>
            </div>
          </nav>
        
          <div class="container-fluid">
            <h1 class="mt-4">Simple Sidebar</h1>
            <p>The starting state of the menu will appear collapsed on smaller screens, and will appear non-collapsed on larger screens. When toggled using the button below, the menu will change.</p>
            <p>Make sure to keep all page content within the <code>#page-content-wrapper</code>. The top navbar is optional, and just for demonstration. Just create an element with the <code>#menu-toggle</code> ID which will toggle the menu when clicked.</p>
          </div>
        </div>
        <!-- /#page-content-wrapper -->
        
          </div>        </div>

          <!-- /#wrapper -->
        
          <!-- Bootstrap core JavaScript -->
        
        
          <!-- Menu Toggle Script -->
    

</body>
</html>

AdemГЎs dejo aquГ - в ссылке в documentaciГіn bootstrap для dropdowns

2
ответ дан 23.12.2019, 22:06

Теги

Похожие вопросы