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.

            
                    <h1>info toggletip test</h1>
<div><button id="doit" aria-describedby="" aria-expanded="false"><img src="http://www.html5accessibility.com/tests/i.png" alt="information"></button> <aside id="tool1" aria-live='polite'><span role='tooltip' >You asked for it and here it is! We hope you enjoy the show. <br> Don't forget to <b>tip</b>. If you have an issue please contact <a href=' https://twitter.com/patrick_h_lauke'>Patrick Lauke</a></span></aside>
  <i>Some text</i> next to the button that could be anything as is unrelated to the pattern.</div>  
<h2>notes:</h2>
<p>From adhoc testing it works across a range of browsers, AT and OS's, including: Firefox, Chrome, IE, Safari, Jaws, Window Eyes, Narrator, VoiceOver, NVDA, Windows and iOS.</p>

            
          
!
            
              body {
  font-family: Tahoma, Geneva, Arial, sans-serif;
}
p {position:relative}
button {
  border: none;
  margin: 0px;
  padding: 0px;
  background:#408840;
  width:19px;
    height:19px;
 
}
button:focus {outline: 2px solid green;
outline-offset: 1px;}

img {margin-bottom: 1px;}
#tool1 {
  z-index:99;
  display: none;
  background: #eee;
	border: 1px solid #ccc;
	padding: 10px;
	border-radius: 8px;
	box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
	position: absolute;
	width: 14m; 
  font-size:.8em;
}


            
          
!
            
              function showtooltip() {
  var e1 = document.getElementById("tool1");
  var b1 = document.getElementById("doit");
  b1.setAttribute("aria-expanded", "true");
 // set the aria-described id ref when displayed 
b1.setAttribute("aria-describedby", "tool1");

  e1.setAttribute("style", "display: block;");
}

function hidetooltip() {
  var e1 = document.getElementById("tool1");
  var b1 = document.getElementById("doit");
  b1.setAttribute("aria-expanded", "false");

  // remove the aria-describedby id ref when hidden
  b1.setAttribute("aria-describedby", "tool1");
  e1.setAttribute("style", "display: none;");
}

function toggleTooltip(e) {
  var e1 = document.getElementById("tool1");
  if (window.getComputedStyle(e1).getPropertyValue('display') === 'none') {

    showtooltip();
  } else {
    hidetooltip();

  }
}

var b1 = document.getElementById("doit");

b1.addEventListener("click", toggleTooltip, false);

document.addEventListener('keyup', function(e) {
  if (e.keyCode == 27) {
    toggleTooltip();
  }
});
            
          
!
999px
🕑 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.

Console