3
Q:

css responsive navigation


  <!-- Load an icon library to show a hamburger menu (bars) on small screens -->

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  
<div class="topnav" 
id="myTopnav">
  <a href="#home" class="active">Home</a>
  
<a href="#news">News</a>
  <a href="#contact">Contact</a>
  
<a href="#about">About</a>
  <a href="javascript:void(0);" 
  class="icon" onclick="myFunction()">
    <i 
  class="fa fa-bars"></i>
  </a>
</div> 
-1

  <!-- Load an icon library to show a hamburger menu (bars) on small screens -->

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  
<div class="topnav" 
id="myTopnav">
  <a href="#home" class="active">Home</a>
  
<a href="#news">News</a>
  <a href="#contact">Contact</a>
  
<a href="#about">About</a>
  <a href="javascript:void(0);" 
  class="icon" onclick="myFunction()">
    <i 
  class="fa fa-bars"></i>
  </a>
</div> 

<script>
  /* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */
function myFunction() {
  var x = document.getElementById("myTopnav");
  if (x.className === "topnav") {
    x.className += " responsive";
  } else {
    x.className = "topnav";
  }
}
  </script
0
#header{
position:fixed;
z-index:1000;
left:0;
top:0;
width:100vw;
height:auto;
}

#header .header{
min-height:8vh;
background-color: rgba(0,0,0,0.3);
}

#header .nav-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  width:100%;
  height:100%;
  max-width:1300px;
  padding:0 10px;
}

#header .nav-list ul{
  list-style:none;
  position:absolute;
  background-color:rgb(31,30,30);
  width:100vw;
  height:100vh;
  left:0;
  top:0;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  z-index:1;
  overflow-x:hidden;
}

#header .nav-list ul a{
  font-size:2.5rem;
  font-weight:500;
  letter-spacing: .2rem;
  text-decoration:none;
  color:white;
  text-transform:uppercase;
  padding:20px;
  display:block;
  
  
}
0

New to Communities?

Join the community