looking for some solutions? You are welcome.

SOLVED: how to show fixed hidden menu in a specific div?

Lou:

I have developed a toggle menu, my code works perfectly without any problem. My menu is ideal to add on an adataptable website.

This is my complete code, fully functional:

$(document).ready(function () {
$('.slideout-menu-toggle').on('click', function(event){
  event.preventDefault();
  var slideoutMenu = $('.slideout-menu');
  var slideoutMenuWidth = $('.slideout-menu').width();
  $('.capa').toggleClass('visible');  
  slideoutMenu.toggleClass("open");
});
});
.slideout-menu {
  position: fixed;
  top: 0;
  left:-250px;
  width: 250px;
  height: 100%;
  background-color: rgba(15, 23, 27, 0.85);
  transition: all .5s cubic-bezier(0.39, 0.575, 0.565, 1);
  z-index: 100;
}
.slideout-menu h3 {
  position: relative;
  padding: 12px 10px;
  color: #fff;
  font-size: 1.2em;
  font-weight: 400;
}
.slideout-menu .slideout-menu-toggle {
  position: absolute;
  top: 12px;
  left: 10px;
  display: inline-block;
  padding: 6px 9px 5px;
  font-weight: bold;
  line-height: 1;
  color: #999;
  vertical-align: top;
}
.slideout-menu .slideout-menu-toggle:hover {
  color: #fff;
}

.slideout-menu ul li a {
  position: relative;
  display: block;
  padding: 10px;
  color: #999;
}

.slideout-menu ul li a:hover {
  background: #000;
  color: #fff;
}

.capa {
  background-color: rgba(0, 0, 0, 0.4);
  height: 100%;
  left: 0;
  opacity: 0;
  position: fixed;
  top: 0;
  transition: all .5s cubic-bezier(0.39, 0.575, 0.565, 1);
  visibility: hidden;
  width: 100%;
  z-index: 10;
}
.capa.visible {
  opacity: 1;
  visibility: visible;
}
.slideout-menu.open {
  left: 0;
}

.bloque {
 margin: 0 auto;
 width: 600px;
 height: 100vh;
 background: bisque;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container-menu-toggle">
                <div class="slideout-menu">
                        <h3>Menu <a href="#" class="slideout-menu-toggle">&times;</a></h3>
                        <ul>
                                <li><a href="#">Home</a></li>
                                <li><a href="#">Home</a></li>
                                <li><a href="#">Home</a></li>
                                <li><a href="#">Home</a></li>
                                <li><a href="#">Home</a></li>
                                <li><a href="#">Home</a></li>
                                <li><a href="#">Home</a></li>
                        </ul>
                </div>
        </div>

        <div class="bloque">
                <div class="boton-menu-toggle">
                        <a href="#" class="slideout-menu-toggle">Menu</a>
                </div>
        </div>

But I would like to be able to make the menu appear and hide from a div specific.

Thus:

enter image description here

And not in this way:

enter image description here

can you explain how to get the hidden menu displayed and hidden in a specific div?



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent