I have created a sprite for my global header. I can get the CSS to work for enabled and hover states but want to move to the current state and I can't figure out how.
Hover CSS - ul#menu li a.contact:hover, ul#awesome-menu li a.contact:focus { background-position: -575px -70px; What do I need for current state? Thank you, Laurie
1st YES - a - for any general styling when left alone and unclicked 2nd YES - a:hover - for any cursor interaction 3rd Maybe - a:active - if the button has just been clicked?
I also want the active state for the current / selected state. The button would remain on "3rd" until clicking on a different link/button.
I think she wants the "Enabled" to be 'currently selected'...? So a highlighted link to indicate that they're on that particular page. (different color than the rest, even when the mouse goes away).
a:active is on mouse press and hold, so that's not really accomplishing what she wants.
You can set a class="current" on your anchor of the page you are on, if you want to do it manually per page, but my favorite is to do jquery url string matching to set the class on the anchor, that way it's dynamic per page.
Am I wrong? Hopefully I helped. If you want the jquery solution let me know, i'll paste it in here :)
Y'all are fabulous. Thanks for helping. Remember, I am using a sprite for my global header. I will see if I can use a class="current" on this site, because I only have 5 pages so far.
BUT, my next project is one with lots of departments (two rows of tabs) so maybe the jquery thing will work. I've not learned that yet. Will I just cut and paste or will I need more education?
Then Just rename 'nav li a' to the id or class that you have your navigation set up as, and make sure you keep the anchor 'a' at the end, example: #mynavigation a
Since you're using a sprite, name each anchor with a class, example: class="about", then in CSS for it's current state write: a.about.current{} to specifically target that anchor and add your sprite styles for it.
It sounds a bit complicated, but all in all not that bad, you end up with a navigation like so:
Also, if you don't care about supporting IE6/7/8 then using :nth-child in your CSS to select the nav item to style instead of using specific class names on each anchor is definitely better, so for About it would be: nav li:nth-child(2) a.current{}
Hope all of this helps you! (there are other technologies that can do this too, like PHP, ColdFusion, ASP, ect, but Jquery's the easiest way to start!)
The image on the home page is nearly 1mb! Imagine somebody on their mobile trying to check out the website! Even on a super high speed connection it won't load instantly. Same thing with the Contact page - try reducing those file sizes!
Enabled CSS - ul#menu li a.contact {
width: 189px; background-position: -575px 0;
Hover CSS - ul#menu li a.contact:hover, ul#awesome-menu li a.contact:focus {
background-position: -575px -70px;
What do I need for current state?
Thank you,
Laurie
so your three states would be...
a - for any general styling when left alone and unclicked
a:hover - for any cursor interaction
a:active - if the button has just been clicked?
i'm also a little confused... sorry
1st YES - a - for any general styling when left alone and unclicked
2nd YES - a:hover - for any cursor interaction
3rd Maybe - a:active - if the button has just been clicked?
I also want the active state for the current / selected state. The button would remain on "3rd" until clicking on a different link/button.
Still clear as mud?
Thanks,
Laurie
a:active is on mouse press and hold, so that's not really accomplishing what she wants.
You can set a class="current" on your anchor of the page you are on, if you want to do it manually per page, but my favorite is to do jquery url string matching to set the class on the anchor, that way it's dynamic per page.
Am I wrong? Hopefully I helped. If you want the jquery solution let me know, i'll paste it in here :)
~ Chris
BUT, my next project is one with lots of departments (two rows of tabs) so maybe the jquery thing will work. I've not learned that yet. Will I just cut and paste or will I need more education?
Thank you,
Laurie
Including the above will get you started (including the Jquery library).
It matches the url string to the href that's in the anchor:
http://mywebsite.com/about.html
would match
Then Just rename 'nav li a' to the id or class that you have your navigation set up as, and make sure you keep the anchor 'a' at the end, example: #mynavigation a
Since you're using a sprite, name each anchor with a class, example: class="about", then in CSS for it's current state write: a.about.current{} to specifically target that anchor and add your sprite styles for it.
It sounds a bit complicated, but all in all not that bad, you end up with a navigation like so:
Also, if you don't care about supporting IE6/7/8 then using :nth-child in your CSS to select the nav item to style instead of using specific class names on each anchor is definitely better, so for About it would be: nav li:nth-child(2) a.current{}
Hope all of this helps you! (there are other technologies that can do this too, like PHP, ColdFusion, ASP, ect, but Jquery's the easiest way to start!)
~ Chris
Thank you Chris for your time.
Laurie
It's still a work in progress, but check it out if you like - LMahoney.com
My top nav still has movement issues but I'm getting there.
Thanks again for all your comments.
Laurie
It's really good to know about that smush it site. I will try it out.
Thanks for taking the time to help.
Laurie