[HTML] Problema con navbar

lorenzomartini

Nuovo Utente
29 Ago 2019
1
0
0
Buongiorno, ho rimediato su internet il codice per una navbar menu che vedete sotto.
Vorrei sapere come posso far si che i sottomenù si aprano con un click e non appena il mouse è "hover" :), in quando se aperto da dispositivo mobile non sono apribili i sottomenu...

HTML:
<style>
.navbar {
  background-color: blue;
}

li {
  font-size: 16px;
}

.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>.dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -6px;
    margin-left: -1px;
    -webkit-border-radius: 0 6px 6px 6px;
    -moz-border-radius: 0 6px 6px;
    border-radius: 0 6px 6px 6px;
}

.dropdown-submenu:hover>.dropdown-menu {
    display: block;
}

.dropdown-submenu>a:after {
    display: block;
    content: " ";
    float: right;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-left-color: #ccc;
    margin-top: 5px;
    margin-right: -10px;
}

.dropdown-submenu:hover>a:after {
    border-left-color: #fff;
}

.dropdown-submenu.pull-left {
    float: none;
}

.dropdown-submenu.pull-left>.dropdown-menu {
    left: -100%;
    margin-left: 10px;
    -webkit-border-radius: 6px 0 6px 6px;
    -moz-border-radius: 6px 0 6px 6px;
    border-radius: 6px 0 6px 6px;
}

</style>

<div class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
            </button>
            <a class="navbar-brand">
              <a href="/gea-web/home.php"><img src="/gea-web/img/logo.png" style="height:40px;margin-right:30px;margin-top:5px;"/></a>
            </a>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><b>Nome * Cognome</b> <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="/gea-web/utente/modificaProfilo.php">Modifica profilo</a></li>
            <li><a href="/gea-web/utente/sessioni.php">Sessioni recenti</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="/gea-web/logout.php">Logout</a></li>
          </ul>
                </li>
            </ul>
            <ul class="nav navbar-nav">
                    <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">MENU 2 <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li class="dropdown-submenu">
                            <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">SUB 1 DI MENU 2</a>
                            <ul class="dropdown-menu">
                                <li><a href="#">Visualizza</a></li>
                                <li><a href="#">Inserisci</a></li>
                                <li class="divider"></li>
                                <li><a href="#">Something else here</a></li>
                                <li class="divider"></li>
                                <li><a href="#">Separated link</a></li>
                                <li class="divider"></li>
                                <li class="dropdown-submenu">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>
                                    <ul class="dropdown-menu">
                                        <li class="dropdown-submenu">
                                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>
                                            <ul class="dropdown-menu">
                                                <li><a href="#">Action</a></li>
                                                <li><a href="#">Another action</a></li>
                                                <li><a href="#">Something else here</a></li>
                                                <li class="divider"></li>
                                                <li><a href="#">Separated link</a></li>
                                                <li class="divider"></li>
                                                <li><a href="#">One more separated link</a></li>
                                            </ul>
                                        </li>
                                    </ul>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </li>
            </ul>
        </div><!--/.nav-collapse -->
    </div>
</div>
 

Discussioni simili