- This topic is empty.
-
AuthorPosts
-
February 18, 2011 at 10:21 pm #31691
buildman
ParticipantWould it be a problem for you to post the way you did the multi-colored nav bar on this site. I love this thing. You’re a great instructor, I took your course on lynda.com and really enjoyed it, highly recommended
Thanks a bunch
James
February 19, 2011 at 1:15 am #59484Ethan27
Memberyeh that would be cool
February 19, 2011 at 9:48 am #59421rickylamerz
MemberI read this, and I found it interesting. So I tried to recreate the menu using CSS and jQuery instead of CSS3 for the animation.
Here’s what I came up with. You can look at the source and copy it.
February 19, 2011 at 10:23 am #59423gno
MemberThe one thing that makes this tricky is that the current page tab is the wider one when no menu-item’s is hovered.
The basics could be accomplished, by CSS3 transitions, but you could do the same with jQuery. And jQuery is required to modify the width of the current page item (at least as far as I know).
Something like this should cover your needs.
$(document).ready(function(){
var hoverWidth = 200;
var normalWidth = 150;
var speedValue = 150;
$('#menu a').mouseover(function(){
$('#menu a').stop().animate({width: normalWidth}, speedValue); // make all #menu a's the non-active width
$(this).stop().animate({width: hoverWidth}, speedValue); // make this #menu a the active width
}).mouseout(function(){
$(this).stop().animate({width: normalWidth}, speedValue); // make this #menu a the non-active width
$('#menu a.active').stop().animate({width: hoverWidth}, speedValue); // make the #menu a.active the active width
});
});For this to work, you should just make a div width an id of menu containing a series of a-tags. The a-tags should have the display property set to inline-block and have a set width which should be the same as the jQuery variable normalWidth. Furthermore you should have the a-tag corresponding to the current page set to the class active – and that class should have the width of the jQuery variable hoverWidth in your stylesheet.
When you got the basics of this up and running you can apply extra styling, like the different colors used here on CSS-tricks.
I guess you could make the jQuery animations as a fallback only used in browsers that does not support css transitions, if you want to go all fancy on this…
February 19, 2011 at 8:31 pm #59347buildman
ParticipantHi gno;
Thanks for responding to my post, it’ll take me a while to get my arms around this because I’m just beginning to get into jquery, it’s great to have some code to start with and especially on a project I’m already into.
This is the first time I’ve posted on this forum, hope I’m getting it right.
Thanks a bunch
James
February 20, 2011 at 3:29 am #59338jamygolden
MemberAnd jQuery is required to modify the width of the current page item (at least as far as I know).
@gno This isn’t true. Disable javascript and have a look. Also inspect what he has done with firebug.It would be overkill to use jQuery for something like that unless you really want the animation to work cross-browser.
February 20, 2011 at 4:34 am #59313Ethan27
Member@rickylamerz Nice effort mate looks really good.
@jamy_za So its possible to write it just using css3….?
February 20, 2011 at 5:17 am #59302jamygolden
Member@Ethan27 It’s not only possible, Chris did it with CSS.
He’s set the with of the UL to 810px.
Each anchor is set to a width of 19%. There are 5 anchors.
The current page nav item is targeted via CSS and set to 24%.
(4 * 19%) + (1 * 24%) = 100%Simply put, it consists of this:
– Current page nav item is set to 24%
– When the UL is hovered upon, all items are set to 19% – including the current page
– Hovering on an item sets the item to 24%
– Essentially two things are happening when you hover on an item. All items are set to 19%, and the item you are hovering on is set to 24%The effects are achieved with css transitions.
http://net.tutsplus.com/tutorials/html-css-techniques/css-fundametals-css-3-transitions/
https://css-tricks.com/video-screencasts/93-css3-slideup-boxes/February 20, 2011 at 5:19 am #59303jamygolden
MemberNote: I’ve changed the title of this post because “Hi Chris” doesn’t have anything to do with this.
February 20, 2011 at 5:43 am #59305Ethan27
MemberNice man Ill have to try it out.
Lol I can see it now an internet covered with chris’ menu.
February 20, 2011 at 6:42 am #59306rickylamerz
Member@Ethan27 Thanks! :)
February 20, 2011 at 4:44 pm #59119TheDoc
MemberThere was an interview that Chris did on another website that explained some of the problems he faced creating the menu and some of the things he had to do to fix it… but I cannot find it!
February 20, 2011 at 6:16 pm #59124chrisburton
Participant@TheDoc This one? http://vimeo.com/19194493
February 21, 2011 at 2:49 am #59140TheDoc
MemberThat’s the one!
February 21, 2011 at 5:24 am #59145chrisburton
ParticipantI like the part where he thought the forum was new.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.