Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div id="intro">
<h1>Giphy ToolTip</h1>
  <p>To test this out, try hovering over the purple word. For a better experience, hover over the purple word more than once.</p>
  <p>Want to test it out on <u>other words</u>? Use the input below (the input in the black box) under "Change Parameter" to insert your own word.</p>
<div id="cont">
  <p>There was once a <span class="tooltip">princess</span> from a very far away land.</p>
  <div id="query">
    <label for="textbox">Change Parameter</label><input id="textbox" type="text" placeholder="e.g. paper, cheese, dog"/>
              @import url(https://fonts.googleapis.com/css?family=Roboto);
$tooltip-color: lighten(mix(blue, yellow, 70%), 10%);
  outline: 0!important
  position: absolute;
  top: 1.5em;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
    max-width: 50%;
    margin: auto;
    margin-bottom: 1em;
  background: #000;
  color: #fff;
  margin: 1em -1.5em -1.5em;
  padding: 0.75em 1.5em 1.5em;
  box-sizing: border-box;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  position: absolute;
  width: 100%;
    padding: 0.5em 1em;
    margin-top: 0.5em;
    width: 100%;
    box-sizing: border-box;
      border: 1px solid mix(white, crimson, 75%);
html, body{
  font-family: 'Roboto', sans-serif;
  height: 100%;
  width: 100%;
  padding: 0;
  margin: 0;
  background: mix(white, red, 85%);
  width: 250px;
  line-height: 1.5em;
  padding: 1.5em;
  border: 1px solid #cecece;
  border-radius: 4px;
  position: relative;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  background: #FFF;
  text-decoration: none;
  color: $tooltip-color;
  font-weight: bold;
  display: inline-block;
  padding: 10px 5px;
    background: mix(white, red, 85%);
  background: #000;
  text-align: center;
  color: #FFF;
  position: absolute;
  left: 0;
  padding: 10px;
    content: ' ';
    display: block;
    position: absolute;
    bottom: -10px;
    left: 50%;
    margin-left: -15px;
    border-right: 10px solid transparent;
    border-top: 15px solid black;
    border-left: 10px solid transparent;
    margin: auto;
              var aList = document.querySelectorAll('.tooltip');
var tooltip = {
  randomGif: function(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
  fadeIn: function(el){
      el.style.opacity = Number(el.style.opacity) + 0.2;
      el.style.top = (Number(el.style.top.replace('px','')) - 2) + 'px';
        return tooltip.fadeIn(el);
      }, 30);
  init: function(el, elX, elY){
    var $el = el, x = elX, y = elY;
      url: 'http://api.giphy.com/v1/gifs/search?q='+ el.innerHTML.replace(/ /g, '+') +'&api_key=dc6zaTOxFJmzC',
      dataType: 'json',
      success: function(gifs){
        var gif = gifs.data[tooltip.randomGif(0,gifs.data.length)].images.fixed_height;
        var gifUrl = gif.url;
        var width = Number(gif.width);
        var height = Number(gif.height);
        tooltip.create(gifUrl, $el, height, width, elX, elY);
  create: function(el, par, elH, elW, elX, elY){
    var tip = document.createElement('div');
    var tipImg = document.createElement('img');
    tipImg.src = el;
    tipImg.style.width = elW/2 + 'px';
    tip.id = 'tooltip';
    tip.style.opacity = 0;
    tip.style.top =  (par.offsetParent.offsetTop - (elH/2) - Number(getComputedStyle(par.offsetParent).height.replace('px',''))) + 40 + 'px';
    tip.style.left =  (par.offsetParent.offsetLeft-((elW/4)-(Number(getComputedStyle(par).width.replace('px',''))/2))+5) + 'px';
  remove: function(el){
for(var i = 0; i<aList.length; i++){
    tooltip.init(e.target, e.clientX, e.clientY);
  document.getElementById('textbox').addEventListener('keyup', function(){
    document.querySelector('.tooltip').innerHTML = document.getElementById('textbox').value;
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.