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

              
                <h1>CSS-only Tooltip</h1>
<p>
  This is just some filler text, but
<span class="tooltip tooltip-bottom" data-tip="yay, tooltip content! provided by your friendly data-* attribute">this thing has a tooltip</span> and here we have more filler text. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<p>
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim. This is just some filler text, but
<span class="tooltip" data-tip="yay, bottom tooltip content! provided by your friendly data-* attribute">this thing has a tooltip</span> and here we have more filler text. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, <span class="tooltip" data-tip="yay, bottom content! provided by your friendly data-* attribute">quis</span> nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
              
            
!

CSS

              
                // CSS-only Tooltip
// work in progress, still needs more testing. So far works well in Chrome, FF, Opera, Safari, IE9-11. 
// IE 8 seems to be ok, just don’t forget fallback colors and visibility: hidden.
// Goals: 
// - Make tooltip work across browsers including IE8
// - Tooltip shows up on either top or bottom of anchor (with extra class .tooltip-bottom added)
// - Tooltip supports multiple line text

@import url(https://fonts.googleapis.com/css?family=Montserrat:700,400);

*, *:before, *:after {
  -moz-box-sizing: border-box; 
  -webkit-box-sizing: border-box; 
  box-sizing: border-box;
}
// this is just for looks
body {
  margin: 1em 2em;
  line-height: 1.5;
  background-color: #EAEAEA;
  color: rgb(0,19,49);
  text-align: left;
  font-family: 'Montserrat', sans-serif;
}
p {
  max-width: 40em;
}

// variables
$tip-distance: 24px;
$tip-triangle-width: 6px;
$tip-color-fallback: #001331;
$tip-color: rgba(0,19,49,.9);
// style the tooltip anchor
.tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
  border-color: $tip-color-fallback; // IE8 fallback
  border-bottom: 1px dotted $tip-color;
  background-color: #EAEADE; // IE8 fallback
  background-color: rgba(255,255,0,.05);
    &:after {
      content: attr(data-tip);
      position: absolute;
      bottom: $tip-distance;
      left: -10px;
      min-width: 100px;
      max-width: 300px;
      padding: 5px 7px 5px 10px;
      pointer-events: none;
      font-size: .75em;
      background-color: $tip-color-fallback;
      background-color: $tip-color;
      color: #FFF;
      border-radius: 2px;
    }
    // this creates the little triangle
    &:before {
      content: "";
      width: 0;
      height: 0;
      position: absolute;
      left: 5px;
      bottom: $tip-distance - $tip-triangle-width;
      border-left: $tip-triangle-width solid transparent;
      border-right: $tip-triangle-width solid transparent;
      border-top: $tip-triangle-width solid $tip-color-fallback; // IE8 fallback
      border-top: $tip-triangle-width solid $tip-color;
    }
    &:before,  
    &:after {
      display: block;
      visibility: hidden; // because opacity:0 is not enough for IE8
      opacity: 0;  
      transition: opacity 0.2s ease-out, margin 0.2s ease-out;
    }
    &:hover {
      color: #999;
      &:before,  
      &:after {
        opacity: 1;
        margin-bottom: 3px;
        visibility: visible;
      }
    }
}

.tooltip-bottom {
  &:after {
    top: $tip-distance;
  }
  &:before {
    top: $tip-distance - $tip-triangle-width;
    border-top: 0;
    border-left: $tip-triangle-width solid transparent;
    border-right: $tip-triangle-width solid transparent;
    border-bottom: $tip-triangle-width solid $tip-color-fallback; // IE8 fallback
    border-bottom: $tip-triangle-width solid $tip-color;
  }
  &:hover {
    &:before,  
    &:after {
      bottom: auto;
      margin-bottom: 0;
      margin-top: 3px;
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console