title: Menu toggle CSS only doesn't work when it is inside the element
body: <p>Edit:</p>
  
  <p>I removed my question. I believe that CSS only isn't a really functional and decent way to code a sliding nav. Therefore I created it with a littlebit jQuery instead.</p>
  
  <p>Working example:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $("#toggle-nav").click(function() {
      $(".main-nav").toggleClass("nav-trans");
    });
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
  }
  .main-nav {
    position: fixed;
    background: #000;
    padding-left: 2em;
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
    color: #fff;
    top: 50%;
    transform: translateY(-50%) translateX(-100%);
    transition: transform 0.6s;
  }
  .main-nav ul {
    list-style-type: none;
    margin-left: -1em;
    padding: 1em 1em 1em 0;
  }
  .main-nav li {
    padding: 1em;
  }
  #toggle-nav {
    width: 4em;
    height: 4em;
    background: #000;
    border-radius: 30em;
    position: absolute;
    right: -1.7em;
    top: 50%;
    transform: translateY(-50%);
    z-index: -1;
  }
  .nav-trans {
    transform: translateY(-50%) translateX(0);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  
  &lt;head&gt;
    &lt;link href="css/style.css" rel="stylesheet"&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script src="js/main.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;nav class="main-nav"&gt;
      &lt;div id="toggle-nav"&gt;&lt;/div&gt;
      &lt;ul&gt;
        &lt;li&gt;pagina1&lt;/li&gt;
        &lt;li&gt;pagina2&lt;/li&gt;
        &lt;li&gt;pagina3&lt;/li&gt;
        &lt;li&gt;pagina4&lt;/li&gt;
        &lt;li&gt;pagina5&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/nav&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Maybe this could help someone in the future.</p>