LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code
  • Item One
  • Item Two
  • Item Three
CSS
@import url(https://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;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

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;
  cursor: pointer;
}

.slider {
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: yellow;
  -webkit-transition: all 0.5s;
  transition: all 0.5s;
}
/*  Ripple */

.ripple {
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  -webkit-transform: scale(0);
          transform: scale(0);
  position: absolute;
  opacity: 1;
}

.rippleEffect {
  -webkit-animation: rippleDrop .6s linear;
          animation: rippleDrop .6s linear;
}

@-webkit-keyframes rippleDrop {
  100% {
    -webkit-transform: scale(2);
            transform: scale(2);
    opacity: 0;
  }
}

@keyframes rippleDrop {
  100% {
    -webkit-transform: scale(2);
            transform: scale(2);
    opacity: 0;
  }
}
JS
$("ul li").click(function(e) {

  // make sure we cannot click the slider
  if ($(this).hasClass('slider')) {
    return;
  }

  /* 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 olds ones
  $(".ripple").remove();

  // Setup
  var posX = $(this).offset().left,
      posY = $(this).offset().top,
      buttonWidth = $(this).width(),
      buttonHeight = $(this).height();

  // Add the element
  $(this).prepend("");

  // 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");
});
Host Instantly Drag and Drop Website Builder

 

Description

Click a tab to see the slider move with a nice ripple effect too.
Term
Mon, 11/27/2017 - 21:49

Related Codes

Pen ID
Pen ID
Pen ID