Hi,
is it possible to format the active menu-element with css (a:active) in Expression Engine.
The menu is generated with channel-entries, not hand-coded.
Thanks
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
November 03, 2011 9:30am
Subscribe [4]#1 / Nov 03, 2011 9:30am
Hi,
is it possible to format the active menu-element with css (a:active) in Expression Engine.
The menu is generated with channel-entries, not hand-coded.
Thanks
#2 / Nov 03, 2011 4:33pm
Sure, just assign a:active selector to your navigation CSS class list, eg
#nav a:link { color: #0000FF; }
#nav a:visited { color: #00FF00; }
#nav a:hover { color: #FF0000; }
#nav a:active { color: #C0C0C0; }
#nav a:focus { color: #555555; }#3 / Nov 03, 2011 9:37pm
Thanks for the assist, Rob.
mtbts - does that info from Rob help?
#4 / Nov 04, 2011 3:25am
Thanks, but that doesn’t work. If i visit a page from the nav here is always the color “#000”.
HTML:
<nav>
<ul>
{exp:channel:entries channel="channel1" dynamic="no"}
<li><a href="http://{url_title_path=">{title}</a></li>
{/exp:channel:entries}
</ul>
</nav>
CSS:
nav li a {
border-right: 1px solid #87888a;
padding: 0 15px;
display: inline-block;
color: #000;
}
nav li a:hover, .contact a:hover {
color: #fff;
}
nav a:active {
color: #fff;
}
#5 / Nov 04, 2011 8:31pm
Mbts,
Are you trying to have the link to the currently viewed page be #fff? If so please add a conditional to your link tag checking that the final url segment matches the url title you should be able to add your class to only that link.
Try placing this bit of code inside your opening a tag link title
{if last_segment=='url_title'}class='current'{/if}'And in your css add
a.current {color:#fff;}If that is not what you are trying to do, could you please clarify your question. Either way please let us know what the results are.
#6 / Nov 08, 2011 1:47am
Thanks Sean,
but it doesn’t work. The menu is generated dynamically. Could this be the reason?
Thanks
#7 / Nov 10, 2011 9:59am
Him mbts.
What part isn’t working? Is there an actual url_title in your url, or not?