I have a HTML/CSS menu with this CSS for the active links:
.navigation ul li a:hover, .navigation .active-nav {
background-color: #F36F25; /*#373737;*/
text-shadow: none;
color: #f7f7f7 !important;
-webkit-box-shadow: 0 3px 0 #ff8833;
box-shadow: 0 3px 0 #ff8833;
}
Fiddle: http://jsfiddle.net/kyvbzssd/
How can I set the top parent link as active if any of its child or its child's child links have an active class?
Add the style to your li element as well : http://jsfiddle.net/kyvbzssd/3/
.navigation ul li{
padding: 80px 9px 10px;
}
.navigation ul li a,.navigation ul li{
font-size: 13px;
font-weight: 700;
color: #4d4d4d;
text-decoration: none;
display: inline-block;
margin-bottom: 0;
text-transform: uppercase;
border-bottom: 2px solid #fff;
-webkit-transition: background-color .2s linear, padding-top .2s linear;
-moz-transition: background-color .2s linear, padding-top .2s linear;
-o-transition: background-color .2s linear, padding-top .2s linear;
-ms-transition: background-color .2s linear, padding-top .2s linear;
transition: background-color .2s linear, padding-top .2s linear;
}
.navigation ul li a:hover,.navigation ul li:hover,.navigation .active-nav {
background-color: #F36F25; /*#373737;*/
text-shadow: none;
color: #f7f7f7!important;
-webkit-box-shadow: 0 3px 0 #ff8833;
box-shadow: 0 3px 0 #ff8833;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With