Menú lateral con Html y Css
by Slee
HTML
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Menù Lateral con Css</title>
<link rel="stylesheet" href="estilos.css">
</head>
<body>
<header class="header">
<div class="container">
<div class="btn-menu">
<label for="btn-menu">☰</label>
</div>
<div class="logo">
<h1>Logotipo</h1>
</div>
<nav class="menu">
<a href="#">Inicio</a>
<a href="#">Nosotros</a>
<a href="#">Blog</a>
<a href="#">Contacto</a>
</nav>
</div>
</header>
<div class="capa"></div>
<!-- --------------->
<input type="checkbox" id="btn-menu">
<div class="container-menu">
<div class="cont-menu">
<nav>
<a href="#">Portafolio</a>
<a href="#">Servicios</a>
<a href="#">Suscribirse</a>
<a href="#">Facebook</a>
<a href="#">Youtube</a>
<a href="#">Instagram</a>
</nav>
<label for="btn-menu">✖️</label>
</div>
</div>
</body>
</html>
CSS
@import url("https://fonts.googleapis.com/css?family=Montserrat|Montserrat+Alternates|Poppins&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Montserrat Alternates", sans-serif;
}
body {
background-image: url("https://cdn.pixabay.com/photo/2023/05/28/09/21/south-tyrol-8023213_1280.jpg");
background-attachment: fixed;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.capa {
position: fixed;
width: 100%;
height: 100vh;
background: rgba(0, 0, 0, 0.6);
z-index: -1;
top: 0;
left: 0;
}
/*Estilos para el encabezado*/
.header {
width: 100%;
height: 100px;
position: fixed;
top: 0;
left: 0;
}
.container {
width: 90%;
max-width: 1200px;
margin: auto;
}
.container .btn-menu,
.logo {
float: left;
line-height: 100px;
}
.container .btn-menu label {
color: #fff;
font-size: 25px;
cursor: pointer;
}
.logo h1 {
color: #fff;
font-weight: 400;
font-size: 22px;
margin-left: 10px;
}
.container .menu {
float: right;
line-height: 100px;
}
.container .menu a {
display: inline-block;
padding: 15px;
line-height: normal;
text-decoration: none;
color: #fff;
transition: all 0.3s ease;
border-bottom: 2px solid transparent;
font-size: 15px;
margin-right: 5px;
}
.container .menu a:hover {
border-bottom: 2px solid #c7c7c7;
padding-bottom: 5px;
}
/*Fin de Estilos para el encabezado*/
/*Menù lateral*/
#btn-menu {
display: none;
}
.container-menu {
position: absolute;
background: rgba(0, 0, 0, 0.5);
width: 100%;
height: 100vh;
top: 0;
left: 0;
transition: all 500ms ease;
opacity: 0;
visibility: hidden;
}
#btn-menu:checked ~ .container-menu {
opacity: 1;
visibility: visible;
}
.cont-menu {
width: 100%;
max-width: 250px;
background: #1c1c1c;
height: 100vh;
position: relative;
transition: all 500ms ease;
transform: translateX(-100%);
}
#btn-menu:checked ~ .container-menu .cont-menu {
transform:...