cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

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>Field tooltips</h1>
<h2>Requirements</h2>
<ul>
  <li>tooltip appears on hover via an icon</li>
  <li>should be available to keyboard users as well (eg on focus)</li>
  <li>useful to SR users to describe the input</li>
  <li>No JS!</li>
  <li>for mobile support (which would required JS), see <a href="https://codepen.io/mpiotrowicz/pen/MYQMdb" target="_blank">this example</a>
</ul>

<label for="address">
  <span class="visuallyhidden">Address</span>
</label>

<input id="address" type="text" placeholder="address" aria-describedby="Tooltip" />

<span tabindex="0" class="btn-tooltip" id="Tooltip" role="tooltip">
  <i class="fa fa-bolt icon" aria-hidden="true"></i>
  <span class="tooltip-content">here's some information.</span>
</span>
            
          
!
            
              // font awesome added for icon
// maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css

body {
  padding: 20px;
}

ul {
  margin-bottom: 20px;
}

input {
  padding: 5px;
  border: 1px solid #999;
  border-radius: 2px;
}

.visuallyhidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

.showvisuallyhidden {
  clip: auto;
  overflow: visible;
}

.btn-tooltip {
  border: none;
  background: none;
  position: relative;
}

.tooltip-content {
  @extend .visuallyhidden;
  height: auto;
  display: block;
  position: absolute;
  
  // styling specific to this example
  bottom: 130%;
  left: 50%;
  z-index: 200;
  width: 180px;
  margin: 0 0 5px -90px;
  padding: 0.75em 1em;
  text-align: center;
  color: #FFF;
  font-size: 12px;
  border-radius: 4px;
  background-color: #474747;
  
  transition: all 0.3s cubic-bezier(0.3, 0, 0, 1);
  transform: rotateX(20deg) scale(0.8);
  transform-origin: center 120%;
  -webkit-backface-visibility: hidden;
  opacity: 0;
}

.btn-tooltip {
  display: inline-block;
  text-align: center;
  // nice big hit area
  min-width: 40px;
  &:focus,
  &:hover {
    .tooltip-content {
      @extend .showvisuallyhidden;
      
      // styling specific to this example
      transform: rotateX(0deg) scale(1);
      opacity: 1;
    }
  }
}


::-webkit-input-placeholder {
 color: #767676;
}
::-moz-placeholder {  
 color: #767676;
} 
            
          
!
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