JSFiddle - React, Tailwind, and code Playground

by francisco_negrao

HTML

<link rel="stylesheet" href="https://componentes.interago.com.br/bootstrap-grid.css">
<link rel="stylesheet" href="https://componentes.interago.com.br/global-css.css">
<header id="js-header" style="transform: translateY(0px)">
  <div class="container">
    <div class="row">
      <div class="col-12">
        <div class="nav-bar">
          <div class="logo">
            <a href="" title="Ir para a Página Inicial" rel="nofollow">
              <picture>
                <source
                  srcset="
                    https://www.ecowd.inf.br/cms/img/dropzone_upload/resized_14613f700d1e453_1631547405_200x.webp
                  "
                  type="image/webp"
                />
                <source
                  srcset="
                    https://www.ecowd.inf.br/cms/img/dropzone_upload/resized_14613f700d1e453_1631547405_200x.jpg
                  "
                  type="image/png"
                />
                <img
                  src="https://www.ecowd.inf.br/cms/img/dropzone_upload/resized_14613f700d1e453_1631547405_200x.webp"
                  alt="Logo Website MODELO 2021"
                  class="img-fluid"
                  loading="lazy"
                />
              </picture>
            </a>
          </div>
          <nav>
            <input class="menu-btn" type="checkbox" id="menu-btn" />
            <label onclick="overlayLeft()" class="menu-icon" for="menu-btn">
              <span class="navicon"></span>
            </label>
            <div id="nav-list">
              <input class="menu-close" type="checkbox" id="menu-close" />
              <label
                class="menu-close-btn"
                for="menu-close"
                onclick="menuToggle()"
              >
                Fechar Menu
              </label>
              <ul>
                <li>
                  <a href="" title="Ir para a página inicial">Página Inicial</a>
                </li>
                <li>
                  <a
         ...

CSS

/* NAVBAR  */ /* PASSO 01. Estilo Barra de Navegação Responsiva */

header {
  box-shadow: 0px 3px 12px rgb(0 0 0 / 10%);
  background-color: #fff;
  position: fixed;
  width: 100%;
  z-index: 999;
  transition: 0.5s all;
}
header .nav-bar {
  display: flex;
  height: 100%;
  position: relative;
  min-height: 90px;
  align-items: center;
}
header .nav-bar nav {
  margin: auto 0px auto auto;
}
header .nav-bar ul {
  padding: 0px;
  margin: 0px;
  list-style: none;
}
header .nav-bar ul > li {
  display: inline-block;
  margin: 0px 10px;
}
header .nav-bar li > a {
  color: #041c27;
  text-decoration: none;
  transition: 0.3s ease;
  padding: 5px 5px;
  font-size: 14px;
  font-weight: 600;
}
header .nav-bar li > a:hover {
  color: #107cac;
}
header .nav-bar ul > li:last-child {
  margin: 0px 0px 0px 6px;
}
header .btn-topbar {
  background-color: #cd3537;
  color: white;
  padding: 5px 20px;
}
.logo {
  position: absolute;
  margin-left: 30px;
}
.logo img {
  max-width: 200px;

}

/* OVERLAY CSS */

#js-header.overlay--left:after {
  content: "";
  background-color: rgb(0 0 0 / 80%);
  width: 100%;
  height: 110vh;
  display: block;
  position: fixed;
  pointer-events: unset;
  z-index: 998;
  top: -39px;
} 

/* PASSO 02. ESTILOS MOBILE */ /* 02.1 Criando Ícone Hamburger */

header .menu-icon {
  cursor: pointer;
  display: none;
  float: right;
  padding: 28px 3px;
  position: relative;
  user-select: none;
}
header .menu-icon .navicon {
  background: #163d4f;
  display: block;
  height: 2px;
  position: relative;
  transition: background 0.2s ease-out;
  width: 18px;
}
header .menu-icon .navicon:before,
header .menu-icon .navicon:after {
  background: #163d4f;
  content: "";
  display: block;
  height: 100%;
  position: absolute;
  transition: all 0.2s ease-out;
  width: 100%;
}
header .menu-icon .navicon:before {
  top: 5px;
}
header .menu-icon .navicon:after {
  top: -5px;
}

/* 02.2 Criando Animação Menu Hamburger */


header .menu-btn {
  display:...

JavaScript

// Scripts responsáveis por colocar um tamanho para a correção do fixed da Navbar      

 document.addEventListener("DOMContentLoaded", function() { 

     // Depois que o documento HTMl é carregado, vamos colocar uma altura na Fixed Correction      

     setTimeout(function(){ 

         // Tempo para carregar todos os elementos que são link externos  

         var fixedCorrection = document.getElementById("js-header").clientHeight;  

         document.getElementById("fixedCorrection").style.height = fixedCorrection+"px";   

          console.log(fixedCorrection);        
          
        }, 1000); 

        });    

          // Script com função de checagem botão hamburger   

          function menuToggle() {      document.getElementById('menu-btn').checked = false;       
           document.getElementById("js-header").classList.remove('overlay--left');      
        }    

           // Script para criar Overlay ao abrir navbar   

           function overlayLeft() {      
               if (document.getElementById('menu-btn').checked) {              
                   document.getElementById("js-header").classList.remove('overlay--left');            
                } else {              document.getElementById("js-header").classList.add('overlay--left');           
             }      
            }