<header>
<h1>Logo</h1>
<input type="checkbox" id="menuToggle">
<label for="menuToggle">☰ Menu</label>
<nav>
<label for="menuToggle">Close</label>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
@import url(https://fonts.googleapis.com/css2?family=Rubik);
:root {
--primary-text-color: #222;
--secondary-text-color: #fff;
--primary-bg-color: #222;
--secondary-bg-color: brown;
}
body {
color: var(--primary-text-color);
font-family: "Rubik", serif;
font-size: 1.2rem;
line-height: 1.6;
}
header {
align-items: center;
display: flex;
justify-content: space-between;
padding: 1rem;
}
h1 {
font-size: inherit;
line-height: inherit;
margin: 0;
}
#menuToggle {
display: none;
}
label {
cursor: pointer;
}
nav {
background-color: var(--primary-bg-color);
color: var(--secondary-text-color);
height: 100vh;
left: 50%;
position: absolute;
text-align: right;
transform: translate(-50%, -50%) scale(0);
top: 50%;
width: 100vw;
}
nav label {
line-height: 3;
margin-right: 1rem
}
ul {
list-style: none;
margin: 0;
padding: 0;
text-align: center;
}
ul a:link,
ul a:visited,
ul a:hover,
ul a:active {
color: var(--secondary-text-color);
}
#menuToggle:checked + label + nav {
transform: translate(-50%, -50%) scale(1);
transition: 0.3s;
}
@media (min-width: 600px) {
header > label,
nav label {
display: none;
}
nav {
background-color: transparent;
color: var(--primary-text-color);
display: flex;
height: auto;
left: auto;
position: relative;
transform: none;
transition: none;
top: auto;
width: auto;
}
ul {
display: flex;
}
ul li {
margin-left: 1rem;
}
ul a:link,
ul a:visited,
ul a:hover,
ul a:active {
color: var(--primary-text-color);
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.