I am currently adding styles to the last child of a navigation menu, and I have been successful with this code:
.aston-menu-light ul > li:last-child {
border:2px solid blue;
border-radius: 50px;
padding:0 20px 0 20px;
}
.aston-menu-light ul > li > ul > li:last-child {
border:none !important;
padding:0 !important;
}
.aston-menu-light ul > li:last-child:hover {
background-color:#ffff;
-webkit-transition: all .5s;
-o-transition: all .5s;
transition: all .5s;
}
However, I am encountering an issue when attempting to target the <a>
tag of the last child on hover. I am using the following code for this:
.aston-menu-light ul > li > a:last-child:hover {
color:red !important;
}
Unfortunately, it seems to be applying the style to all <a>
tags instead of just the last child. I have experimented with different variations such as ul > li a
, but I cannot seem to get it to work correctly.
You can view my Codepen here: https://codepen.io/shaun-taylor/pen/LXdGGN
The main objective is to make only the last link in the top level turn red when hovered over. Thank you for taking the time to read!