cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <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-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(http://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;
    }
  }
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console