Estructura responsiva

Ejercicio para practicar habilidades de HTML y CSS. Generamos una estructura HTML con menú de opciones que se adapta todos los dispositivos el el llamado menú tipo persiana.

Podés visitar el ejercicio que desarrollaremos aquí

💻 Ver explicación en video de youtube.

HTML

<!DOCTYPE html>
<html lang="es">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="stylesheet" href="style.css">
   <title>Documento web responsivo</title>
</head>
<body>
   <header>
       <nav class="contenedor">
           <a href="#inicio" id="logo">🤖 Logomanía</a>
           <input type="checkbox"  id="abrir-menu">
           <ul class="opciones">
               <li><a href="#inicio">inicio</a></li>
               <li><a href="#productos">productos</a></li>
               <li><a href="#nosotros">nosotros</a></li>
               <li><a href="#contacto">contacto</a></li>
           </ul>
           <label for="abrir-menu">
               <span></span>
               <span></span>
               <span></span>
           </label>
       </nav>
   </header>
   <main>
       <section id="inicio">inicio</section>
       <section id="productos">productos</section>
       <section id="nosotros">nosotros</section>
       <section id="contacto">contacto</section>
   </main>
   <footer>
       <div class="contenedor">
           <a href="https://codigoenweb.com">Creado por <span>codigoenweb.com</span> - <strong>2026</strong></a>
           <ul class="opciones">
               <li><a href="#inicio">inicio</a></li>
               <li><a href="#productos">productos</a></li>
               <li><a href="#nosotros">nosotros</a></li>
               <li><a href="#contacto">contacto</a></li>
           </ul>

       </div>
   </footer>

   <script src="script.js"></script>
</body>
</html>

CSS

   *{
       margin: 0;
       padding: 0;
       box-sizing: border-box;
   }
   html{
       scroll-behavior: smooth;
       scroll-padding-top: 5rem;
   }
   ::-webkit-scrollbar{
       width: 0.5rem;
   }
   ::-webkit-scrollbar-track{
       background: transparent;
   }
   ::-webkit-scrollbar-thumb{
       background:orange;
       border-radius: 2rem;
   }
   ::selection{
       background-color: orange;
   }
   a{
       text-decoration: none;
       color: inherit;
   }
   ul{
       list-style: none;
   }
   #abrir-menu{
       display: none;
   }
   body{
       font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
       font-size: 1.5rem;
   }
   .contenedor{
       width: min(calc(100% - 32px), 1200px);
       margin: 0 auto;
       padding-block: 1.5rem;
   }

   header{
       position: sticky;
       top:0;
       right: 0;
       left:0;
       background-color: orange;
       box-shadow: 2px 2px 2px rgba(0,0,0,0.09);
       z-index: 10;
   }

   header nav{
       display: flex;
       justify-content: space-between;
       align-items: center;
   }
   header nav ul.opciones{
       display: flex;
       gap:3rem;
       text-transform: capitalize;
   }
   header nav ul.opciones li:hover a{
   color:#333;
   }

   header nav label{
       width: 2rem;
       height: 1.5rem;
       cursor: pointer;

       display: none;
       flex-direction: column;
       justify-content: space-around;
   }
   header nav label span{
       width: 100%;
       height: 3px;
       background-color: black;
       transition: 0.3s linear;
   }

   section{
       min-height: 100vh;
       display: grid;
       place-items: center;
       font-size: 4rem;
       text-transform: uppercase;
       border-bottom: 4px solid orange;
   }

   footer{
       background-color: #333;
       color: white;
       font-size: 0.9rem;
   }
   footer .contenedor{
       display: flex;
       justify-content: space-between;
       flex-wrap: wrap;
       gap:0.5rem;

   }
   footer ul.opciones{
       text-transform: capitalize;
       display: flex;
       gap:2rem;
   }

   @media (max-width:768px) {
       header nav label{
           display: flex;
       }
       header nav ul.opciones{
           position: absolute;
           top: 99%;
           left: 0;
           right: 0;
           display: inline-block;
           padding-left: 2rem;
           padding-top: 2rem;
           padding-bottom: 2rem;
           background-color: orange;
           border-top: 1px solid rgba(0,0,0,0.09);
           border-bottom: 1px solid rgba(0,0,0,0.09);
           clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
           transition: 0.3s linear;
       }
       header nav ul.opciones li{
           margin: 1rem 0;
       }
       #abrir-menu:checked ~ ul.opciones{
           clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
       }
       #abrir-menu:checked ~ label span:nth-child(2){
           opacity: 0;
       }
       #abrir-menu:checked ~ label span:nth-child(1){
           transform: rotate(45deg) translateY(8px)
       }
       #abrir-menu:checked ~ label span:nth-child(3){
           transform: rotate(-45deg) translateY(-12px) translateX(2px)
       }
   }

Javascript

   window.onscroll = ()=>{
       document.querySelector('#abrir-menu').checked = false;
   }

Recursos

Íconos menú y cerrar : https://fonts.google.com