title: Foundation - fade out an overlay that was faded in previously?
body: <p>I manage to fade in an overlay when the button is clicked:</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-js lang-js prettyprint-override"><code>$(".button-toggle-overlay-menu").on("click", function() {
    $("#menu").toggleClass("is-open");
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>/* 
      Overlay menu
      http://zurb.com/old-bbs/overlay-navigation-menu 
      */
  
  .button-toggle-overlay-menu {
    position: relative;
    font-size: 4rem;
    z-index: 5000;
    color: #333;
    top: -0.5rem;
    left: 1.5rem;
    transition: all 0.4s ease-in-out;
  }
  
  .button-toggle-overlay-menu:hover {
    transition: all 0.4s ease-in-out;
    color: gray;
  }
  
  .overlay-menu {
    position: absolute;
    z-index: 1000;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 20px;
    list-style: none;
    background: rgb(255, 255, 255);
    /* Fall-back for browsers that don't support rgba */
    background: rgba(255, 255, 255, .9);
    display: none;
    text-align: center;
    animation: fadeOut 1s;
  }
  
  @keyframes fadeOut {
    from {
      opacity: 1;
    }
    to {
      opacity: 0;
    }
  }
  
  .overlay-menu li {
    display: block;
  }
  
  .overlay-menu a {
    display: inline-block;
    color: #000;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
    text-decoration: none;
  }
  
  .overlay-menu a:hover {
    color: #808080;
  }
  
  .overlay-menu.is-open~.button-toggle-overlay-menu {
    display: inline-block;
    transition: all 0.4s ease-in-out;
    transform: rotate(135deg);
    color: #000;
  }
  
  .is-open {
    display: block;
    /* 
        Fade in the overlay 
        http://stackoverflow.com/questions/11679567/using-css-for-fade-in-effect-on-page-load
        */
    -webkit-animation: fadein 1s;
    /* Safari, Chrome and Opera &gt; 12.1 */
    -moz-animation: fadein 1s;
    /* Firefox &lt; 16 */
    -ms-animation: fadein 1s;
    /* Internet Explorer */
    -o-animation: fadein 1s;
    /* Opera &lt; 12.1 */
    animation: fadein 1s;
  }
  
  @keyframes fadein {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
  
  
  /* Firefox &lt; 16 */
  
  @-moz-keyframes fadein {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
  
  
  /* Safari, Chrome and Opera &gt; 12.1 */
  
  @-webkit-keyframes fadein {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
  
  
  /* Internet Explorer */
  
  @-ms-keyframes fadein {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
  
  
  /* Opera &lt; 12.1 */
  
  @-o-keyframes fadein {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;link href="http://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css" rel="stylesheet"&gt;
  
  &lt;nav role="navigation"&gt;
    &lt;ul id="menu" class="overlay-menu"&gt;
      &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#"&gt;Contact&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;a class="button-toggle-overlay-menu" href="#menu"&gt;&lt;i class="fi-plus"&gt;&lt;/i&gt;&lt;/a&gt;
  &lt;/nav&gt;
  
  &lt;div class="title-bar" data-responsive-toggle="example-menu" data-hide-for="medium"&gt;
    &lt;button class="menu-icon" type="button" data-toggle&gt;&lt;/button&gt;
    &lt;div class="title-bar-title"&gt;Menu&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="top-bar" id="example-menu"&gt;
    &lt;div class="top-bar-left"&gt;
      &lt;ul class="dropdown menu" data-dropdown-menu&gt;
        &lt;li class="menu-text"&gt;Site Title&lt;/li&gt;
        &lt;li&gt;
          &lt;a href="#"&gt;One&lt;/a&gt;
          &lt;ul class="menu vertical"&gt;
            &lt;li&gt;&lt;a href="#"&gt;One&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Two&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Three&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt;Two&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt;Three&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
    &lt;div class="top-bar-right"&gt;
      &lt;ul class="menu"&gt;
        &lt;li&gt;&lt;input type="search" placeholder="Search"&gt;&lt;/li&gt;
        &lt;li&gt;&lt;button type="button" class="button"&gt;Search&lt;/button&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;h1&gt;Hello, world!&lt;/h1&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But I want to fade the overlay out when the button is clicked to close. I am not sure how to do it. Any ideas?</p>