Index.html
I am using two different directories for storing black and white images and color images. So all the black and white images are in “bw” folder and all the color images are in “color” folder. When first time menu loads we will show bw images and on mouse over event we will replace that “bw” folder name with “color” so bw images will become colorful and it will give a fancy look to the navigation menu.
As i said earlier i am using “-moz”,”-webkit-” and “-o-” so it can work in all the browsers. Internet explorer doesnt support css3 transition property yet so what we can do it just hope that next version of IE will support it. And this is what we have done till date, we are just hoping hoping and hoping but IE never keep up with other browsers.
Anyways lets have a look at the code. I am using DIVs and anchor tag to create navigation menu, i am not sure but this could be also designed using UL and LI’s also, I tried but i wasnt able to give it proper look that i wanted so went with DIV’s.
style.css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
body{ font-family: verdana; background: #fff; } .menu{ float: right; } .menu .item{ float: left; margin-left: 5px; width: 150px; height: 80px; padding-top: 60px; background: #F7F7F7; text-align: center; color: #444444; box-shadow: inset 0 0 10px #C0C0C0; text-shadow:1px 1px 1px rgba(255, 255, 255, 0.5), 1px 1px 1px rgba(0, 0, 0, 0.7); border-radius: 0px 0px 8px 8px; -moz-transition: all 0.5s linear 0s; -webkit-transition: all 0.5s linear 0s; -o-transition: all 0.5s linear 0s; } .menu a{ text-decoration: none; } .menu .item:hover{ color: #fff; box-shadow: inset 0 0 8px #6C6C6C; } .menu .home:hover{ background-color: #ADB7FA; } .menu .client:hover{ background-color: #A0D856; } .menu .tech:hover{ background-color: #15A697; } .menu .career:hover{ background-color: #C2BF2E; } .menu .contact:hover{ background-color: #E9B672; } |
Jquery
1 2 3 4 5 6 7 8 9 10 11 12 |
$(document).ready(function(){ $(".item").mouseenter(function(){ var src = $(this).find("img").attr("src"); var npath = src.replace("bw","color"); $(this).find("img").attr("src",npath); }); $(".item").mouseleave(function(){ var src = $(this).find("img").attr("src"); var npath = src.replace("color","bw"); $(this).find("img").attr("src",npath); }); }); |
Excellent use of CSS3 and Jquery Amit…
Loved Demo of Navigation..
You can also add hover jquery selector to make extra fun in demo.