- This topic is empty.
January 21, 2015 at 6:10 am #193805
I have a problem, sort of. I want to achieve something like this:
Let’s say I have a menu like this:
<li class="first"> item 1</li>
<li class="second"> item 2</li>
<li class="third"> item 3</li>
Is it possible to have an css class added to the whole page based on the css class of the active menu Item? When the item with CSS class #second is clicked for example, the whole page to get #whatever class?
Thank you for any help.January 21, 2015 at 6:15 am #193806
It’s not clear what you are trying to do.
If you click on
li.secondyou want the
bodyto get the
.secondclass…is that right?
Doable…but why?January 21, 2015 at 6:49 am #193807
Thank you. I’m building a template for a small cms with various sections that have specific css classes attached to their menu intems only.January 21, 2015 at 7:22 am #193809
OK, but I’m not sure what the clicking of a list item will do for you.
Regardless, I’ve used Jquery abovebut it does remove all classes from the body so the script is very powerful and easy to be overused. You may need to adapt the script.January 21, 2015 at 7:40 am #193814
Well, I want to achieve this situation: when testimonials menu tab is clicked so, I’m in the testimonials page the links colour( for example) of that page to be red, not dark blue as default … ans so on. And this CMS doesn’t have the flexibillity of something like WordPress to have individual page classes.January 21, 2015 at 7:44 am #193815
Hmm, OK but you’re gonna get the ‘flash’ of styling switch, It would be ‘preferable’, I feel, to have the styling applied as the page is loaded.
Anyway, it’s up to you.January 21, 2015 at 11:27 am #193844justdanParticipant
If the color switch is too flashy you could always give the body.first/second/third a transition property of “transition: all .3s linear 0s;” and it’ll at least make it a little smoother and easier on the eyes.January 21, 2015 at 12:13 pm #193850
You have to be careful with a transition of “all” otherwise you can get some odd effects.
I would only transition the properties that I want to affect.January 21, 2015 at 12:18 pm #193855