/ Dropdown Menu

Drops down on click by the use of a hidden checkbox

Drops down on click by the use of a hidden checkbox

CSS DROPDOWN MENU

Full CSS dropdown navigation. Drops down on click by the use of a hidden checkbox.

Made with

Html
Css

html

<h1>CSS Dropdown Menu</h1>

<nav>

  <label for="touch"><span>titre</span></label>               
  <input type="checkbox" id="touch"> 

  <ul class="slide">
    <li><a href="#">Lorem Ipsum</a></li> 
    <li><a href="#">Lorem Ipsum</a></li>
    <li><a href="#">Lorem Ipsum</a></li>
    <li><a href="#">Lorem Ipsum</a></li>
  </ul>

</nav> 

Css

/* Générales */

body {background-color : #ededed; font-family : "Open Sans", sans-serif;}

h1 {padding: 40px; text-align: center; font-size: 1.5em;}

li a {text-decoration : none; color : #2d2f31;}

/* Nav */

nav {
  width : 300px; 
  background: #d9d9d9; /* Couleur de fond des liens */
  margin : 40px auto; /* Marge à virer */
}

/* Titre */

span {
  padding : 30px;
  background : #2d2f31; /* Couleur de l'en-tête */
  color : white;
  font-size : 1.2em;
  font-variant : small-caps;
  cursor : pointer;
  display: block;
}

span::after {
  float: right;
  right: 10%;
  content: "+";
}

/* Liste */

.slide {
  clear:both;
  width:100%;
  height:0px;
  overflow: hidden;
  text-align: center;
  transition: height .4s ease;
}

.slide li {padding : 30px;}

/* Checkbox */

#touch {position: absolute; opacity: 0; height: 0px;}    

#touch:checked + .slide {height: 300px;} /* Hauteur à gérer en fonction du nombre de liens */ 

Demo

See the Pen CSS Dropdown Menu by Rlski (@remilaudanski) on CodePen.

CodeTea

A Nice collection of often useful examples done in HTML JavaScript CSS.

Read More