I have this CSS on my WordPress website that will change the font-size to 2em of the main navigation menu items when hovering. What I need is to make it so that it remains with that font-size while going to the sub-items. Is there a way to achieve this inside of WordPress?
.menu a:hover {
font-size:2em !important;
transition-duration: all .2s !important;
}
That is the code I’m using right now, and I added the main menu items that .menu class.
I gave the sub-items a .submenu-item class. So what I researched is that using something like this could do the trick:
.submenu-item:hover + .menu-about {
font-size:2em !important;
transition-duration: 0.05s;
}
But it doesn’t. I’ve tried using > and ~ and neither of those worked. Is there a way to do it?
Thanks a lot in advance!
2
Answers
I have checked your site and hope this CSS will work for you.
And make sure you do not add
!important
if it is not override with other css.According to this question it is not recommended or even possible to access the parent element with only CSS. You can do that with JavaScript as the codes below:
I don’t know how exactly you could add that codes to your WordPress codes (I’m not very professional in WordPress). But if you search, maybe found the way. Also for the last tip: it is not correct to say
transition-duration: all .2s
(that you mentioned in the question), the correct way istransition-duration: .2s
ortransition: all .2s
.