<div class="container">
<nav>
<input id="toggle" type="checkbox" checked>
<h2>Drop Down Menu</h2>
<ul>
<li><a href="#chapter1">Chapter 01</a></li>
<li><a href="#chapter2">Chapter 02</a></li>
<li><a href="#chapter3">Chapter 03</a></li>
<li><a href="#chapter4">Chapter 04</a></li>
</ul>
</nav>
<h2 id="chapter1">Some chapter about wheat.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<h2 id="chapter2">Some chapter about wheat.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<h2 id="chapter3">Some chapter about wheat.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<h2 id="chapter3">Some chapter about wheat.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<h2 id="chapter4">Some chapter about wheat.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex molestiae sint corrupti excepturi consequuntur sequi, enim adipisci aperiam iure nobis nesciunt tempora itaque, quos officia mollitia recusandae asperiores. Dignissimos?
</p>
</div>
body {
background: #ece5da;
font-family: "Raleway", sans-serif;
color: ivory;
font-size: 20px;
}
nav {
margin: auto;
margin-top: 40px;
position: relative;
width: clamp(320px, 50vw ,100%);
}
nav h2 {
font-size: 1.5rem;
border-radius: 2px;
position: relative;
background: tomato;
height: 40px;
text-transform: uppercase;
margin-bottom: 0;
color: inherit;
font-weight: 200;
display: flex;
flex: 1;
justify-content: center;
align-items: center;
box-shadow: 4px 4px 20px -2px rgba(0, 0, 0, 0.35);
transition: all 0.4s;
}
nav:hover h2 {
transform: translateY(-2px);
box-shadow: 2px 2px 5px -1px rgba(0, 0, 0, 0.35);
transistion: all 0.4s;
}
#toggle {
position: absolute;
left: 0;
top: 0;
width: 100%;
z-index: 1;
opacity: 0;
cursor: pointer;
height: 40px;
}
h2::before{
position: absolute;
right: 0;
top: 0;
height: inherit;
aspect-ratio: 1;
background: currentColor;
display: flex;
align-items: center;
padding-right: 1rem;
content: "";
clip-path: polygon(50% 25%, 20% 80%, 80% 80%);
transform: rotate(180deg) scale(0.75);
}
#toggle:not(:checked) ~ h2::before {
transform: rotate(0deg) scale(0.75);
}
#toggle:focus ~ h2{
background: mediumorchid;
transition: background 0.45s;
}
#toggle:checked ~ ul {
visibility: hidden;
opacity: 0;
}
#toggle:not(:checked) ~ ul {
opacity: 1;
transition: opacity 0.3s ease-in-out;
}
nav ul {
padding-left: 0;
padding-top: 1rem;
margin-top: 0;
background: #ece5da;
list-style: none;
overflow: hidden;
text-align: right;
text-align: center;
transition: all 0.4s ease-out;
width: 100%;
position: absolute;
}
nav ul li {
border-radius: 2px;
position: relative;
display: inline-block;
line-height: 1.5;
width: 100%;
margin: 0 0 0.25rem 0;
background: tomato;
transition: background 3s;
box-shadow: 2px 2px 10px -2px rgba(0, 0, 0, 0.35);
}
nav ul li:hover,
nav ul li a:focus {
background: mediumorchid;
transition: background 0.45s;
}
nav ul a {
display: block;
color: inherit;
text-transform: lowercase;
font-weight: 200;
text-decoration: none;
}
.container {
max-width: 55ch;
margin: auto;
color: #36454F;
}
// let links = document.querySelectorAll('ul > li > a');
// links.forEach(link => link.addEventListener('click', (e)=> console.log(e.target.innerText)))
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.