Hello, Welcom to this basic tutorial about creating A beauty design for a Slider Menu.
In the HTML, first thing we should create is the list of menu items: DIGITAL, SERVICE and MARKETPLACE.
<ul> <li>Digital</li> <li>Services</li> <li>MarketPlace</li> <li class="slider"></li> </ul>
So that's All.
Now let's change Style:
The Style code is to make the background of the menu as a blue color the font and color of the writing thinks that are so easy on a CSS3:
@import url(http://fonts.googleapis.com/css?family=Lato:100,300,400,700); * { box-sizing: border-box; } body { font-family: 'Lato', sans-serif; background: #222; } ul { font-size: 0; position: relative; padding: 0; width: 480px; margin: 40px auto; } li { display: inline-block; width: 160px; height: 60px; background: #39CCCC; font-size: 16px; text-align: center; line-height: 60px; color: #fff; text-transform: uppercase; position: relative; overflow: hidden; } .slider { display: block; position: absolute; bottom: 0; left: 0; height: 4px; background: yellow; transition: all 0.5s; } /* Ripple */ .ripple { width: 0; height: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.4); transform: scale(0); position: absolute; opacity: 1; } .rippleEffect { animation: rippleDrop .6s linear; } @keyframes rippleDrop { 100% { transform: scale(2); opacity: 0; } }
No to add some mouvements and make it a dynamic Slider menu we will add some javascript Codes:
$("ul li").click(function(e) { /* Add the slider movement */ // what tab was pressed var whatTab = $(this).index(); // Work out how far the slider needs to go var howFar = 160 * whatTab; $(".slider").css({ left: howFar + "px" }); /* Add the ripple */ // Remove any old one $(".ripple").remove(); // Setup var posX = $(this).offset().left, posY = $(this).offset().top, buttonWidth = $(this).width(), buttonHeight = $(this).height(); // Add the element $(this).prepend("<span class='ripple'></span>"); // Make it round! if (buttonWidth >= buttonHeight) { buttonHeight = buttonWidth; } else { buttonWidth = buttonHeight; } // Get the center of the element var x = e.pageX - posX - buttonWidth / 2; var y = e.pageY - posY - buttonHeight / 2; // Add the ripples CSS and start the animation $(".ripple").css({ width: buttonWidth, height: buttonHeight, top: y + 'px', left: x + 'px' }).addClass("rippleEffect"); });
Finish.
Please Leave a Comment or send me a message about this tutorial if you need help.
0 Comments:
Post a Comment
Thank for leaving a comment