portfolio created by nav links and toggle button using html css and java script

 

this is a website created by html css and java script

code below this image





html , CSS, java script code :--

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Sticky Navbar & Footer</title>
  <!-- <link rel="stylesheet" href="style.css" /> -->
   <style>
    * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  height: 100%;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background: #333;
  color: white;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar a {
  color: white;
  text-decoration: none;
  margin-left: 15px;
}

#nav-links {
  display: flex;
}

.hamburger {
  display: none;
  font-size: 24px;
  cursor: pointer;
}

/* Content */
.content {
  flex: 1;
  padding: 20px;
}

/* Footer */
.footer {
  background: #222;
  color: white;
  text-align: center;
  padding: 15px;
  position: sticky;
  bottom: 0;
  z-index: 100;
}

/* Responsive */
@media (max-width: 768px) {
  #nav-links {
    display: none;
    flex-direction: column;
    background: #444;
    position: absolute;
    top: 50px;
    right: 0;
    width: 200px;
  }

  #nav-links a {
    margin: 10px;
  }

  .hamburger {
    display: block;
  }

  #nav-links.show {
    display: flex;
  }
}

   </style>

</head>
<body>

  <header class="navbar">
    <div class="logo">MySite</div>
    <nav id="nav-links">
      <a href="#">Home</a>
      <a href="#">About</a>
      <a href="#">Services</a>
      <a href="#">Contact</a>
    </nav>
    <div class="hamburger" onclick="toggleMenu()">☰</div>
  </header>

  <main class="content">
    <h1>Welcome to MySite</h1>
    <p>This is a sample responsive page with sticky navbar and footer.</p>
    <p>Scroll down to see the sticky behavior.</p>
    <div style="height: 800px;"></div>
  </main>

  <footer class="footer">
    © 2025 MySite. All rights reserved.
  </footer>

  <!-- <script src="script.js"></script> -->
   <script>
    function toggleMenu() {
  document.getElementById("nav-links").classList.toggle("show");
}

   </script>
</body>
</html>

toggle with image



Comments