Header Dinamico Responsive 2

by Slee

HTML

<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <title>Header responsive con Html y Css</title>
  <link rel="stylesheet" href="estilos.css">
</head>
<body>
  <header class="header">
    <div class="container">
      <div class="logo">
        <h1>SLee Dw</h1>
      </div>
      <div class="boton">
        <label for="btn-menu">Menú</label>
      </div>
      <input type="checkbox" id="btn-menu">
      <nav class="menu">
        <a href="#">Inicio</a>
        <a href="#">Servicios</a>
        <a href="#">Blog</a>
        <a href="#">Contacto</a>
      </nav>
    </div>
  </header>
</body>
</html>

CSS

@import url('https://fonts.googleapis.com/css?family=Montserrat&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Montserrat', sans-serif;
}

.header {
  width: 100%;
  height: 75px;
  background: #101922;
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  box-shadow: 0px 1px 10px rgba(0,0,0,0.4);
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: auto;
  display: flex;
  justify-content: space-between;
}

.logo h1 {
  color: #fff;
  font-weight: 400;
  font-size: 24px;
  cursor: default;
  line-height: 60px;
}

.menu {
  display: flex;
  align-items: center;
}

.menu a {
  color: #fff;
  text-decoration: none;
  padding: 10px 15px;
  font-size: 14px;
  transition: all 500ms ease;
  border-bottom: 4px solid transparent;
}

.menu a:hover {
  color: #40de32;
  border-bottom: 4px solid #40de32;
}

/* Estilos para el botón de menú */
#btn-menu {
  display: none;
}

.boton {
  display: none;
  line-height: 60px;
}

.boton label {
  color: #fff;
  background: #2a343e;
  padding: 5px;
  font-size: 14px;
  border-radius: 3px;
  cursor: pointer;
}

/* Código para dispositivos móviles */
@media only screen and (max-width: 768px) {
  .header {
    height: 60px;
  }

  .container {
    justify-content: space-between;
  }

  .logo h1 {
    font-size: 18px;
  }

  .menu {
    position: absolute;
    background: #234;
    width: 100%;
    height: 100vh;
    top: 60px;
    left: 0;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    transform: translateX(-100%);
    transition: transform 500ms ease;
  }

  #btn-menu:checked ~ .menu {
    transform: translateX(0);
  }

  .menu a {
    display: block;
    margin-top: 10px;
  }

  .boton {
    display: block;
  }
}