Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <!-- this tool uses "cash", a lightweight jQuery alternative. the very first script is needed on your site (usually in the <head></head> tags) to use the tooltip code. -->

<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/8.1.0/cash.min.js"></script>
<div class="container">
  <p>I was having trouble finding a straightforward code for a <span class="tooltip-container"><a href="#" class="tooltip">tooltip</a>. <span class="tooltip-content">Tooltips are pretty cool, huh!</span></span> I prefer having to click to interact with them because hovering is not mobile friendly.</p>

  <p>You can add as many tooltips as you <a href="#" class="tooltip">want</a>. <span class="tooltip-content"><strong>They can be <em>styled</em> too</strong> It's just a div! To close it, you can click on the word <em>or</em> the tooltip.</span>

  <p>These play nice even when a tooltip is used in the middle of a paragraph, just like <span class="tooltip-container"><a href="#" class="tooltip">this one</a>! <span class="tooltip-content">It always goes right below the word that is clicked.</span></span> That's pretty convenient for having extra sidenotes on your website and stuff.</p>

  <!-- You can copy everything in this box and paste it onto your page, and it should work. 
       Basically, tooltips just need this HTML:
       <span class="tooltip-container">
          <a href="#" class="tooltip">TOOLTIP LINK NAME</a>
          <span class="tooltip-content">TOOLTIP CONTENT</span>
       </span> 
-->

              
            
!

CSS

              
                  .container {
      /* .container is just for the demo */
      width: 50%;
      font-family: sans-serif;
    }

    .tooltip {
      border-bottom: 2px dotted #ca82ff;
      /* this is the purple dots underline */
      cursor: pointer;
      text-decoration: none;
    }

    .tooltip a {
      color: #ca82ff;
      /* color of tooltip link text */
    }

    .tooltip-content {
      position: absolute;
      display: none;
      padding: 10px 20px 10px 20px;
      font-size: 14px;
      line-height: 1.3em;
      z-index: 999;
      margin-top: 20px;
      max-width: 400px;
      /* tooltip content width */
      border: 1px solid gray;
      /* tooltip content border */
      z-index: 9999;
      background-color: white;
      /* tooltip background color */
}
              
            
!

JS

              
                  $(".tooltip").on("click", function(event) {
      var tooltipContent = $(this).parent().children(".tooltip-content");
      if (tooltipContent.css("display") === "none") {
        // this gets the position of the link being clicked
        var pos = $(this).position();
        var left = pos.left;
        var top = pos.top;
        // this reveals the tooltip content and positions it
        tooltipContent.css({
          "display": "inline-block",
          "top": top,
          "left": left
        });
        event.preventDefault();
      } else {
        // this hides the tooltip when the link is clicked
        tooltipContent.css("display", "none");
        event.preventDefault();
      }
    });
    // this hides the tooltip when the tooltip content is clicked
    $("span.tooltip-content").on("click", function(event) {
      $(this).css("display", "none");
    });
              
            
!
999px

Console