Menu not showing up (css checkbox)

2.1k Views Asked by At

i'm converting my website to concrete5. This website is supposed to be responsive. So i'm trying to make a responsive menu for smaller screens.

However, when i click on my menu button, the menu doesn't show up (it doesn't switch to display:block).

Code:

CSS:

 /*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ ul.nav {
    display: block;
}

HTML (pulled from concrete5):

 <div id="navwrapper">
  <label for="show-menu" class="show-menu">Show Menu</label>
  <input type="checkbox" id="show-menu" role="button">
  <div id="menu">
    <div id="test" class=" ccm-block-styles">
      <ul class="nav">
        <li class="nav-selected nav-path-selected"><a href="/" target="_self" class="nav-selected nav-path-selected">Home</a></li>
        <li class=""><a href="/index.php/biography/" target="_self" class="">biography</a></li>
        <li class=""><a href="/index.php/sculptures/" target="_self" class="">sculptures</a></li>
        <li class=""><a href="/index.php/drawings/" target="_self" class="">drawings</a></li>
        <li class=""><a href="/index.php/paintings/" target="_self" class="">paintings</a></li>
        <li class=""><a href="/index.php/installation/" target="_self" class="">installation</a></li>
        <li class=""><a href="/index.php/studio/" target="_self" class="">studio</a></li>
        <li class=""><a href="/index.php/info/" target="_self" class="">info</a></li>
        <li class=""><a href="/index.php/contact/" target="_self" class="">contact</a></li>
      </ul>
    </div>
    <div id="links" class=" ccm-block-styles">
      <p><a href="https://www.facebook.com/erlend.vanlandeghem?fref=ts" target="_blank"><img src="/files/cache/3ae097c24f710271444b8d9e77aab5d4_f38.png" alt="facebook.png" width="20" height="20"></a>&nbsp;&nbsp;<img src="/files/cache/5d2604980ec06d13bb257fec2ed03283_f36.png" alt="Linkedin.png" width="20" height="20">&nbsp;&nbsp;<a href="mailto:[email protected]"><img src="/files/cache/0e6dbc07cf49fee9d65a14a779ce2eff_f37.png" alt="mail.png" width="20" height="20"></a></p>
    </div>
1

There are 1 best solutions below

11
On BEST ANSWER

Check how general sibling selector work. This will work if you use Adjacent sibling selector(+):

 /*Show menu when invisible checkbox is checked*/ 
input[type=checkbox]:checked ~ #menu{ display: none; }
<div id="navwrapper">
  <label for="show-menu" class="show-menu">Show Menu</label>
  <input type="checkbox" id="show-menu" role="button">
  <div id="menu">
    <div id="test" class=" ccm-block-styles">
      <ul class="nav">
        <li class="nav-selected nav-path-selected"><a href="/" target="_self" class="nav-selected nav-path-selected">Home</a>
        </li>
        <li class=""><a href="/index.php/biography/" target="_self" class="">biography</a>
        </li>
        <li class=""><a href="/index.php/sculptures/" target="_self" class="">sculptures</a>
        </li>
        <li class=""><a href="/index.php/drawings/" target="_self" class="">drawings</a>
        </li>
        <li class=""><a href="/index.php/paintings/" target="_self" class="">paintings</a>
        </li>
        <li class=""><a href="/index.php/installation/" target="_self" class="">installation</a>
        </li>
        <li class=""><a href="/index.php/studio/" target="_self" class="">studio</a>
        </li>
        <li class=""><a href="/index.php/info/" target="_self" class="">info</a>
        </li>
        <li class=""><a href="/index.php/contact/" target="_self" class="">contact</a>
        </li>
      </ul>
    </div>
    <div id="links" class=" ccm-block-styles">
      <p>
        <a href="https://www.facebook.com/erlend.vanlandeghem?fref=ts" target="_blank">
          <img src="/files/cache/3ae097c24f710271444b8d9e77aab5d4_f38.png" alt="facebook.png" width="20" height="20">
        </a>&nbsp;&nbsp;
        <img src="/files/cache/5d2604980ec06d13bb257fec2ed03283_f36.png" alt="Linkedin.png" width="20" height="20">&nbsp;&nbsp;
        <a href="mailto:[email protected]">
          <img src="/files/cache/0e6dbc07cf49fee9d65a14a779ce2eff_f37.png" alt="mail.png" width="20" height="20">
        </a>
      </p>
    </div>