I have a traditional header, which thanks to @hugocsl, which helped me in this question , a transition of colors, when a menu item is in hover
. Everything works fine, what I want now is to keep the same effect, in addition to hover
, also with focus/active
h1 {
padding: 0;
margin: 0;
color: #fff
}
header {
padding: 0;
margin: 0;
position: relative;
}
header::after {
content: "";
position: absolute;
background: gray;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -2;
}
.header-content {
/* background: gray; */
padding: 30px;
}
.nav {
background: #333;
height: 60px;
/* position: relative; */
}
.nav ul {
float: left;
}
.nav ul,
.nav ul li {
line-height: none;
padding: 0;
margin: 0;
}
.nav ul li {
display: inline-block;
/* position: relative; */
vertical-align: top;
}
/* cores no hover */
.nav ul li:hover::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
transition: 1s;
}
.nav ul li#menu-item-1:hover::after {
background: gray;
}
.nav ul li#menu-item-2:hover::after {
background: green;
}
.nav ul li#menu-item-3:hover::after {
background: blue;
}
.nav ul li#menu-item-4:hover::after {
background: red;
}
.nav ul li#menu-item-5:hover::after {
background: gold;
}
.nav ul li#menu-item-6:hover::after {
background: lime;
}
.nav ul li a {
display: block;
line-height: 60px;
text-decoration: none;
padding: 0 30px;
color: #fff;
}
.nav ul li a:hover {
color: #AAA
}
<header>
<div class="header-content">
<h1 class="logo">Header Colorido on Hover</h1>
</div>
<nav class="nav">
<ul>
<li class="menu-item" id="menu-item-1"><a href="#">Header Cinza</a></li>
<li class="menu-item" id="menu-item-2"><a href="#">Verde</a></li>
<li class="menu-item" id="menu-item-3"><a href="#">Azul</a></li>
<li class="menu-item" id="menu-item-4"><a href="#">Vermelho</a></li>
<li class="menu-item" id="menu-item-5"><a href="#">Gold</a></li>
<li class="menu-item" id="menu-item-6"><a href="#">Lime</a></li>
</ul>
</nav>
</header>