When I use inspect to try my website’s responsiveness everything is fine on mobile and tablet or iPad but there is just one problem. when I hover over the toggle close and open it turns blue when I click it is still white and I hover out of it it turns blue I have tried multiple things.
<nav>
<ul class="menu">
<li class="logo"><a href="https://uprightcode.com/">Upright Code</a></li>
<li class="item"><a href="https://uprightcode.com/">Home</a></li>
<li class="item"><a href="#About">About</a></li>
<li class="item"><a href="#plans">Plans</a></li>
<li class="item"><a href="https://uprightcode.com/Lessons">Lessons</a>
</li>
<li class="toggle"><a href="#"><i class="fas fa-bars"></i></a></li>
</ul>
</nav>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
nav {
background-color: #000;
padding: 0 15px;
font-family: 'Open Sans';
font-weight: 600;
position: fixed;
top: 0;
z-index:10;
width:100%;
}
nav a {
color: white;
text-decoration: none;
}
nav a:hover {
color: rgb(233, 221, 221);
}
.logo {
font-size: 20px;
padding: 7.5px 10px 7.5px 0;
}
.item {
padding: 10px;
}
/* Mobile menu */
.menu {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
margin: unset;
}
.menu li a {
display: block;
padding: 15px 5px;
}
.menu li.subitem a {
padding: 15px;
}
.toggle {
order: 1;
font-size: 20px;
color: white;
}
.toggle:hover {
color: white;
}
.toggole:active {
color: white;
}
.item {
order: 3;
width: 100%;
text-align: center;
display: none;
}
.active .item {
display: block;
}
/* Tablet menu */
@media all and (min-width: 700px) {
.menu {
justify-content: center;
}
.logo {
flex: 1;
}
.toggle {
flex: 1;
order: 2;
color: white;
}
}
/* Desktop menu */
@media all and (min-width: 960px) {
.menu {
align-items: flex-start;
flex-wrap: nowrap;
background: none;
}
.logo {
order: 0;
}
.item {
order: 1;
position: relative;
display: block;
width: auto;
}
.submenu-active .submenu {
display: block;
position: absolute;
left: 0;
top: 68px;
background: #111;
}
.toggle {
display: none;
}
.submenu-active {
border-radius: 0;
}
}
Since it has to do with the mobile menu it may be my javascript submenu toggle.
/* Toggle mobile menu */
function toggleMenu() {
if (menu.classList.contains("active")) {
menu.classList.remove("active");
toggle.querySelector("a").innerHTML = "<i class='fas fa-bars'></i>";
} else {
menu.classList.add("active");
toggle.querySelector("a").innerHTML = "<i class='fas fa-times'></i>";
}
}
/* Event Listeners */
toggle.addEventListener("click", toggleMenu, false);
for (let item of items) {
if (item.querySelector(".submenu")) {
item.addEventListener("click", toggleItem, false);
}
item.addEventListener("keypress", toggleItem, false);
}
document.addEventListener("click", closeSubmenu, false);
Don’t forget your awesome font 5 guys!
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">