HTML

<!DOCTYPE html>

<html>
<head>
  <meta charset="UTF-8">
  <title>CSS Expandable Menu</title>
      <link rel="stylesheet" href="style.css">
</head>

<body>

  <div class="main">
  <input type="checkbox">
    <span></span>
    <span></span>
	  <span></span>
    <div class="menu">
      <li><a href="#">Home</a></li>
      <li><a href="#">Design</a></li>
      <li><a href="#">Development</a></li>
      <li><a href="#">SEO</a></li>
      <li><a href="#">Contact</a></li>
    </div>
</div>
  
</body>
</html>

CSS

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #FF4D50;
    font-family: 'Open Sans', Verdana, Geneva, Tahoma, sans-serif;
}
body, .main, .menu {
    display: flex;
    justify-content: center;
    align-items: center;
}
.main {
    position: relative;
    background-color: #fff;
    padding: 20px;
    transition: 0.5s;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 8px 15px rgba(0,0,0,.2);
}
.menu {
    margin: 0;
    padding: 0;
    width: 0;
    overflow: hidden;
    transition: 0.5s;
}
.main input:checked ~ .menu {
    width: 500px;
}
.menu li {
    list-style: none;
    margin: 0 10px;
}
.menu li a {
    text-decoration: none;
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
    transition: 0.5s;
}
.menu li a:hover {
    color: #161919;
}
.main input {
    width: 40px;
    height: 40px;
    cursor: pointer;
    opacity: 0;
}
.main span {
    position: absolute;
    left: 30px;
    width: 30px;
    height: 4px;
    border-radius: 50px;
    background-color: #666;
    pointer-events: none;
    transition: 0.5s;
}
.main input:checked ~ span {
    background-color: #FF4D50;
}
.main span:nth-child(2) {
    transform: translateY(-8px);
}
.main input:checked ~ span:nth-child(2) {
    transform: translateY(0) rotate(-45deg);
}
.main span:nth-child(3) {
    transform: translateY(8px);
}
.main input:checked ~ span:nth-child(3) {
    transform: translateY(0) rotate(45deg);
}
.main input:checked ~ span:nth-child(4) {
    display: none;
}
Categorie: Appunti

0 commenti

Lascia un commento