Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                  <main id="martini-box">
    <p id="martini-text"> The Martini, a breakdown of the Gentleman's drink </p>
    <div class="slider fade one">
      <svg version="1.1" id="martini" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 595.3 841.9" style="enable-background:new 0 0 595.3 841.9;" xml:space="preserve">
        <g id="olive" class="stayHere">
          <line class="st0" x1="441.7" y1="187.6" x2="355.5" y2="322.2" />

          <ellipse transform="matrix(0.5395 -0.842 0.842 0.5395 15.3108 456.2295)" class="st1" cx="424.7" cy="214.1" rx="14.2" ry="20.8" />
          <path class="st2" d="M432.3,230.5c4.3-0.3,7.9-2,9.9-5.1c2-3.1,2.1-7.1,0.5-11.1L432.3,230.5z" />

          <ellipse transform="matrix(0.5395 -0.842 0.842 0.5395 -13.7086 454.2149)" class="st1" cx="408.4" cy="239.6" rx="14.2" ry="20.8" />
          <path class="st2" d="M416,256c4.3-0.3,7.9-2,9.9-5.1c2-3.1,2.1-7.1,0.5-11.1L416,256z" />
        </g>
        <path id="stem" class="moveHere st3" d="M287.1,413.8c0,0,3.6-2.4,2.9,3.9c-0.7,6.3,3.6,188.5,3.6,188.5l-60.5,15.3c3.6,3.6,64.5,0,64.5,0
        s53.9,3.2,63.3,0.6c0.5-0.1,0.4-0.8,0-0.9L302,606.2c-0.2-0.1-0.4-0.2-0.3-0.4c0.2-8.9,4.3-182,3.6-188.1c-0.6-5.2,1.8-4.5,2.6-4.1
        L287.1,413.8z" />
        <path id="gin" class="moveHere st4" d="M174.7,286.4c39.8,46.3,112.4,127.4,112.4,127.4l20.9-0.2c0.2,0.1,0.4,0,0.5-0.1
        c4.6-5.1,73.7-82.4,112.1-127.2H174.7z" />
        <path id="vermouth" class="moveHere st5" d="M420.6,286.4c15-17.5,25.3-30,25.3-31.4c0-4.8-4.4-6.3-5-6.5c0,0-0.1,0-0.1,0H154.4
        c0,0-5.1,1.5-5.1,6.6c0,1.4,10.3,13.9,25.3,31.4H420.6z" />
      </svg>
    </div>

    <div class="slider fade two">
      <svg version="1.1" id="martini" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 595.3 841.9" style="enable-background:new 0 0 595.3 841.9;" xml:space="preserve">
        <g id="olive" class="moveHere">
          <line class="st0" x1="441.7" y1="187.6" x2="355.5" y2="322.2" />

          <ellipse transform="matrix(0.5395 -0.842 0.842 0.5395 15.3108 456.2295)" class="st1" cx="424.7" cy="214.1" rx="14.2" ry="20.8" />
          <path class="st2" d="M432.3,230.5c4.3-0.3,7.9-2,9.9-5.1c2-3.1,2.1-7.1,0.5-11.1L432.3,230.5z" />

          <ellipse transform="matrix(0.5395 -0.842 0.842 0.5395 -13.7086 454.2149)" class="st1" cx="408.4" cy="239.6" rx="14.2" ry="20.8" />
          <path class="st2" d="M416,256c4.3-0.3,7.9-2,9.9-5.1c2-3.1,2.1-7.1,0.5-11.1L416,256z" />
        </g>
        <path id="stem" class="stayHere st3" d="M287.1,413.8c0,0,3.6-2.4,2.9,3.9c-0.7,6.3,3.6,188.5,3.6,188.5l-60.5,15.3c3.6,3.6,64.5,0,64.5,0
        s53.9,3.2,63.3,0.6c0.5-0.1,0.4-0.8,0-0.9L302,606.2c-0.2-0.1-0.4-0.2-0.3-0.4c0.2-8.9,4.3-182,3.6-188.1c-0.6-5.2,1.8-4.5,2.6-4.1
        L287.1,413.8z" />
        <path id="gin" class="moveHere st4" d="M174.7,286.4c39.8,46.3,112.4,127.4,112.4,127.4l20.9-0.2c0.2,0.1,0.4,0,0.5-0.1
        c4.6-5.1,73.7-82.4,112.1-127.2H174.7z" />
        <path id="vermouth" class="moveHere st5" d="M420.6,286.4c15-17.5,25.3-30,25.3-31.4c0-4.8-4.4-6.3-5-6.5c0,0-0.1,0-0.1,0H154.4
        c0,0-5.1,1.5-5.1,6.6c0,1.4,10.3,13.9,25.3,31.4H420.6z" />
      </svg>
    </div>

    <div class="slider fade three">
      <svg version="1.1" id="martini" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 595.3 841.9" style="enable-background:new 0 0 595.3 841.9;" xml:space="preserve">
        <g id="olive" class="moveHere">
          <line class="st0" x1="441.7" y1="187.6" x2="355.5" y2="322.2" />

          <ellipse transform="matrix(0.5395 -0.842 0.842 0.5395 15.3108 456.2295)" class="st1" cx="424.7" cy="214.1" rx="14.2" ry="20.8" />
          <path class="st2" d="M432.3,230.5c4.3-0.3,7.9-2,9.9-5.1c2-3.1,2.1-7.1,0.5-11.1L432.3,230.5z" />

          <ellipse transform="matrix(0.5395 -0.842 0.842 0.5395 -13.7086 454.2149)" class="st1" cx="408.4" cy="239.6" rx="14.2" ry="20.8" />
          <path class="st2" d="M416,256c4.3-0.3,7.9-2,9.9-5.1c2-3.1,2.1-7.1,0.5-11.1L416,256z" />
        </g>
        <path id="stem" class="moveHere st3" d="M287.1,413.8c0,0,3.6-2.4,2.9,3.9c-0.7,6.3,3.6,188.5,3.6,188.5l-60.5,15.3c3.6,3.6,64.5,0,64.5,0
        s53.9,3.2,63.3,0.6c0.5-0.1,0.4-0.8,0-0.9L302,606.2c-0.2-0.1-0.4-0.2-0.3-0.4c0.2-8.9,4.3-182,3.6-188.1c-0.6-5.2,1.8-4.5,2.6-4.1
        L287.1,413.8z" />
        <path id="gin" class="stayHere st4" d="M174.7,286.4c39.8,46.3,112.4,127.4,112.4,127.4l20.9-0.2c0.2,0.1,0.4,0,0.5-0.1
        c4.6-5.1,73.7-82.4,112.1-127.2H174.7z" />
        <path id="vermouth" class="moveHere st5" d="M420.6,286.4c15-17.5,25.3-30,25.3-31.4c0-4.8-4.4-6.3-5-6.5c0,0-0.1,0-0.1,0H154.4
        c0,0-5.1,1.5-5.1,6.6c0,1.4,10.3,13.9,25.3,31.4H420.6z" />
      </svg>
    </div>

     <div class="slider fade four">
       <svg version="1.1" id="martini" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 595.3 841.9" style="enable-background:new 0 0 595.3 841.9;" xml:space="preserve">
         <g id="olive" class="moveHere">
           <line class="st0" x1="441.7" y1="187.6" x2="355.5" y2="322.2" />

           <ellipse transform="matrix(0.5395 -0.842 0.842 0.5395 15.3108 456.2295)" class="st1" cx="424.7" cy="214.1" rx="14.2" ry="20.8" />
           <path class="st2" d="M432.3,230.5c4.3-0.3,7.9-2,9.9-5.1c2-3.1,2.1-7.1,0.5-11.1L432.3,230.5z" />

           <ellipse transform="matrix(0.5395 -0.842 0.842 0.5395 -13.7086 454.2149)" class="st1" cx="408.4" cy="239.6" rx="14.2" ry="20.8" />
           <path class="st2" d="M416,256c4.3-0.3,7.9-2,9.9-5.1c2-3.1,2.1-7.1,0.5-11.1L416,256z" />
         </g>
         <path id="stem" class="moveHere st3" d="M287.1,413.8c0,0,3.6-2.4,2.9,3.9c-0.7,6.3,3.6,188.5,3.6,188.5l-60.5,15.3c3.6,3.6,64.5,0,64.5,0
         s53.9,3.2,63.3,0.6c0.5-0.1,0.4-0.8,0-0.9L302,606.2c-0.2-0.1-0.4-0.2-0.3-0.4c0.2-8.9,4.3-182,3.6-188.1c-0.6-5.2,1.8-4.5,2.6-4.1
         L287.1,413.8z" />
         <path id="gin" class="moveHere st4" d="M174.7,286.4c39.8,46.3,112.4,127.4,112.4,127.4l20.9-0.2c0.2,0.1,0.4,0,0.5-0.1
         c4.6-5.1,73.7-82.4,112.1-127.2H174.7z" />
         <path id="vermouth" class="stayHere st5" d="M420.6,286.4c15-17.5,25.3-30,25.3-31.4c0-4.8-4.4-6.3-5-6.5c0,0-0.1,0-0.1,0H154.4
         c0,0-5.1,1.5-5.1,6.6c0,1.4,10.3,13.9,25.3,31.4H420.6z" />
       </svg>
    </div>

    <a class="prev">&#10094;</a>
    <a class="next">&#10095;</a>

    <div style="text-align:center">
      <span class="dot" data-hover=" Lorem Dot 1"></span>
      <span class="dot" data-hover=" Lorem Dot 2"></span>
      <span class="dot" data-hover=" Lorem Dot 3"></span>
      <span class="dot" data-hover=" Lorem Dot 4"></span>
    </div>
  </main>

  <div id="hover">HOVER OVER ME
    <span class="hover-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi debitis aliquam alias officiis quisquam doloribus, blanditiis, voluptatibus eius nam hic consequuntur neque, fugit non similique, dolorem sit voluptatem possimus harum earum commodi delectus eveniet dignissimos. Consectetur recusandae, voluptatum vel voluptatem!</span>
  </div>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.2/TweenMax.min.js"></script>
              
            
!

CSS

              
                #martini-box {
  max-width: 1000px;
  position: relative;
  margin: auto;
  text-align: center;
  border: 5px solid rgba(85, 107, 47, 0.7);
}

p {
  width: 50%;
  position: absolute;
  top: 40%;
  left: 25%;
  z-index: 1;
  display: block;
  text-align: center;
  line-height: 1.5;
}


.slider {
  display: none;
  width: 100%;
}

.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  margin-top: -22px;
  padding: 16px;
  color: #ddd;
  font-weight: bold;
  font-size: 18px;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
}

.prev {
  left: 0;
  border-radius: 3px 0 0 3px;
}

.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

.prev:hover, .next:hover {
  background-color: rgba(85, 107, 47, 0.7);
}

.numbertext {
  color: #000;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

.dot {
  cursor: pointer;
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active, .dot:hover {
  background-color: #717171;
}

.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {opacity: .4}
  to {opacity: 1}
}

@keyframes fade {
  from {opacity: .4}
  to {opacity: 1}
}

svg {width: 50%;}
.st0{fill:none;stroke:#CB9866;stroke-miterlimit:10;}
.st1{fill:#666633;stroke:#666633;stroke-miterlimit:10;}
.st2{fill:#F26722;stroke:#F26722;stroke-miterlimit:10;}
.st3{fill:#FAFAFF;stroke:#c0c0c0;stroke-miterlimit:10;}
.st4{fill:#D2EDF3;stroke:#c0c0c0;stroke-miterlimit:10;}
.st5{fill:#FCF9CE;stroke:#c0c0c0;stroke-miterlimit:10;}

#hover{
  position: absolute;
  top: 5%;
  left: 45.5%;
  border: 1px solid black;
  cursor: url(cursor.png), auto;
}

#hover .hover-text {
    visibility: hidden;
    width: 180px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 20px;
    position: absolute;
    top: 160%;
    left: 180%;
}

#hover:hover .hover-text {
    visibility: visible;
    opacity: 1;
}

              
            
!

JS

              
                console.clear();

// Declaring the variables for the slider
var slideElements = Array.from(document.querySelectorAll(".slider"));
var dotElements = Array.from(document.querySelectorAll(".dot"));
var prevButton = document.querySelector(".prev");
var nextButton = document.querySelector(".next");

var currentIndex = 0;
var slides = slideElements.map(hoverFunction);
var currentSlide = slides[currentIndex];

addListeners();
currentSlide.enter();

// Function for the Slider
function showSlide(index) {

  if (index < 0) {
    index = slides.length - 1;
  } else if (index > slides.length - 1) {
    index = 0;
  }

  if (currentIndex === index) {
    return;
  }

  var oldSlide = currentSlide;
  currentIndex = index;
  currentSlide = slides[currentIndex];

  oldSlide.leave();
  currentSlide.enter();
}

function addListeners() {

  dotElements.forEach(function(dot, index) {
    dot.addEventListener("click", function() {
      showSlide(index);
    });
  });

  prevButton.addEventListener("click", function() {
    showSlide(currentIndex - 1);
  });

  nextButton.addEventListener("click", function() {
    showSlide(currentIndex + 1);
  });
}

// Function for the Hover-Effect
function hoverFunction(element, index) {

  var stayHere = element.querySelector(".stayHere");
  var moveHere = element.querySelectorAll(".moveHere");
  var hover = document.getElementById("hover");

  let mouseOverAnimation = new TimelineMax({ paused: true })
    .to(stayHere, 0.5, { x: -100, scale: 1 }, 0)
    .to(moveHere, 0.5, { x: -1000 }, 0)

  hover.addEventListener("mouseenter", mouseEnter);
  hover.addEventListener("mouseleave", mouseLeave);

  leave();

  function mouseEnter() {
    mouseOverAnimation.play();
  }

  function mouseLeave() {
    mouseOverAnimation.reverse();
  }

  function enter() {
    element.style.display = "block";
  }

  function leave() {

    mouseOverAnimation.reversed(false).pause(0);
    element.style.display = "none";
  }

  return {
    element: element,
    enter: enter,
    leave: leave
  };
}

// Function for the martini-box Rotating into the screen
  TweenMax.fromTo("#martini-box", 2, {
  x: -1000,
  opacity: 0,
}, {
  x: 0,
  opacity: 1,
  rotation: 360
});

// Function for the martini-text fading in and then fading out again
TweenMax.fromTo("#martini-text", 1, {
  delay: 2,
  autoAlpha: 0,
}, {
  delay: 1.2,
  autoAlpha: 1,
  ease: Quad.easeInOut,
  scale: 2,
  transformOrigin: "50% 50% -0px",
  yoyo: true,
  repeat: 1,
  repeatDelay: 1.6
});

// Function for the martini to fade in after the martini-text fades out
TweenMax.fromTo("#martini, #hover", 1, {
  opacity: 0,
}, {
  delay: 4,
  opacity: 1
});

//------ Setting elements
//-----------------------------------------------------
let $textDisplay = $('.hover-text'),
      $dot = $('.dot'),
      current = 0,
      btnPrev = $('.prev'),
      btnNext = $('.next');


//------ Dots Click Event
//-----------------------------------------------------
$dot.click(function(){
  current = $dot.index(this);
  $textDisplay.text($(this).data('hover'));
  TweenMax.to($dot, .8, {opacity: .2});
  TweenMax.to(this, .8, {opacity: 1});
});

//------ Next & Prev Click Events
//-----------------------------------------------------
btnPrev.click(function(){
  if(current > 0) {
  current--;
  $dot.eq(current).trigger('click');
    
  }
                 
})

btnNext.click(function(){
  if(current < $dot.length - 1) {
  current++;
  $dot.eq(current).trigger('click');
  }
                 
})
              
            
!
999px

Console