Funcionalidad de cierre
Lección 12 de 13 del curso Barra lateral | Proyecto Front-end de Coddy.
Ahora que el estilo está listo, ¡añadamos la funcionalidad de clic!
Desafío
FácilEn el módulo de javascript, selecciona el id #closeSidebarBtn, y después de hacer clic en él, establece la propiedad right de la clase 'sidebar' a -250px.
Pruébalo tú mismo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Mobile Sidebar</title>
</head>
<body>
<button id="openSidebarBtn">Open</button>
<div id="sidebar" class="sidebar">
<button id="closeSidebarBtn">Close</button>
<!-- Your sidebar content goes here -->
<p>Home</p>
<p>About</p>
<p>Services</p>
<p>Contact</p>
</div>
<script src="script.js"></script>
</body>
</html>
Todas las lecciones de Barra lateral | Proyecto Front-end
1Introducción
¿Qué vas a construir?