title: bootstrap 4 responsive full screen overlay menu
body: <p>I am trying to figure out a way to combine an animated hamburger menu in bootstrap 4 with a full screen menu overlay. Problem: when I set data-toggle="modal" on the button, I get the modal overlay but the animation of the collapsed hamburger menu ("X") in the background (i.e. underneath the overlay) becomes inactive.</p>
  
  <p>On the other hand, when I replace the "modal" attribute with "collapse", the hamburger animation works fine but the overlay menu does not appear.</p>
  
  <p>Is there a simple way to combine these two functions?</p>
  
  <p>This is the CSS:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    padding-top: 5rem;
    margin: 0;
    background: url(../assets/original/test.jpg) no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-repeat: no-repeat;
  }
  
  .base-layout {
    padding: 3rem 1.5rem;
    text-align: center;
  }
  
  
  /* Navbar responsive toggler + hamburger animation */
  
  .navbar-toggler {
    border: none;
    background: transparent !important;
    float: left !important;
    margin-left: 15px;
    margin-right: 0;
  }
  
  .navbar-toggler:focus {
    outline: none;
    background: transparent !important;
  }
  
  .navbar-toggler .icon-bar {
    background-color: #fff;
    transform: rotate(0deg) translate(0px, 0px);
    transition: ease all .2s;
  }
  
  .navbar-toggler .icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 1px;
  }
  
  .navbar-toggler .icon-bar+.icon-bar {
    margin-top: 4px;
  }
  
  
  /*.icon-bar:nth-child(2) {
        width: 16px;
        transition: ease all .2s;
      }*/
  
  .navbar-toggler:hover&gt;.icon-bar:nth-child(2) {
    width: 22px;
    transition: ease all .2s;
  }
  
  .navbar-toggler:active&gt;.icon-bar:nth-child(2) {
    width: 22px;
    transition: ease all .2s;
  }
  
  .navbar-toggler:not(.collapsed) .icon-bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 4px);
    transition: ease all .2s;
  }
  
  .navbar-toggler:not(.collapsed) .icon-bar:nth-child(2) {
    opacity: 0;
    transition: ease all .2s;
  }
  
  .navbar-toggler:not(.collapsed) .icon-bar:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
    transition: ease all .2s;
  }
  
  
  /* Modal */
  
  .modal-nav-content {
    width: 100%;
    height: auto;
  }
  
  .modal-nav-body {
    margin-top: 100px;
  }
  
  .modal-nav-body ul {
    list-style-type: none;
    color: white;
    margin: 0;
    padding: 0;
    width: 100%;
  }
  
  .modal-nav-body ul li {
    text-align: center;
    font-size: 130%;
    padding: 8px;
    text-transform: uppercase;
  }
  
  This is the HTML code:</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;head&gt;
    &lt;!-- Bootstrap core CSS --&gt;
    &lt;link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"&gt;
  
    &lt;!-- Custom styles for this template --&gt;
    &lt;link rel="stylesheet" type="text/css" href="css/custom.css"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
    &lt;!-- Navbar --&gt;
    &lt;nav class="navbar navbar-expand-md navbar-dark bg-transparent fixed-top"&gt;
  
      &lt;span class="navbar-brand" href="#"&gt;&lt;/span&gt;
  
      &lt;!-- data-toggle="modal" :: COLLAPSE --&gt;
      &lt;button type="button" class="navbar-toggler collapsed btn-open" data-toggle="modal" data-target="#nav-modal" aria-controls="nav-modal" aria-expanded="false" aria-label="Toggle navigation"&gt;
            &lt;span class="icon-bar top-bar"&gt;&lt;/span&gt;
            &lt;span class="icon-bar middle-bar"&gt;&lt;/span&gt;
            &lt;span class="icon-bar bottom-bar"&gt;&lt;/span&gt;
            &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
        &lt;/button&gt;
  
    &lt;/nav&gt;
  
    &lt;!-- Modal --&gt;
    &lt;div class="modal fade" id="nav-modal" tabindex="-1" role="dialog"&gt;
      &lt;div class="modal-dialog" role="document"&gt;
        &lt;div class="modal-nav-content"&gt;
          &lt;div class="modal-nav-body"&gt;
            &lt;ul class="wrap-nav"&gt;
              &lt;li class="nav-item active"&gt;
                &lt;a class="nav-link" href="#"&gt;Home &lt;span class="sr-only"&gt;(current)&lt;/span&gt;&lt;/a&gt;
              &lt;/li&gt;
              &lt;li class="nav-item"&gt;
                &lt;a class="nav-link" href="#"&gt;Nav menu item #1&lt;/a&gt;
              &lt;/li&gt;
              &lt;li class="nav-item"&gt;
                &lt;a class="nav-link" href="#"&gt;Nav menu item #2&lt;/a&gt;
              &lt;/li&gt;
              &lt;li class="nav-item"&gt;
                &lt;a class="nav-link" href="#"&gt;Nav menu item #3&lt;/a&gt;
              &lt;/li&gt;
              &lt;li class="nav-item"&gt;
                &lt;a class="nav-link" href="#"&gt;Nav menu item #4&lt;/a&gt;
              &lt;/li&gt;
            &lt;/ul&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
    &lt;main role="main" class="container"&gt;
      &lt;div class="base-layout text-white text-left"&gt;
        &lt;h1&gt;Title&lt;/h1&gt;
        &lt;p class="lead"&gt;Lead text...&lt;/p&gt;
      &lt;/div&gt;
    &lt;/main&gt;
  
  
    &lt;!-- Bootstrap core JavaScript placed at the end of the document so the pages load faster --&gt;
  &lt;script src="https://bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>