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

              
                <div class="buddypress-wrap">

<h1>BP Tooltips Playground - Alt</h1>
  [under construction]
<p>For: <a  href="https://buddypress.trac.wordpress.org/ticket/7188">BP Trac #7188</a></p>
<p>Second pass - Pattern for accessible tooltips usable in all devices. 
  <ul>
    <li>Add <em>bptooltip</em> class and <em>data-bptooltip</em> attribute to the link or button</li>
    <li>Add an <em>aria-label</em> attribute within the link or button for screen-readers if additional information is needed.</li>
    <li>Add <em>aria-hidden="true"</em> to the <em>spans</em> which contain the icon or svg elements.</li>
  </ul>
  
<h2>A. Icon Fonts in empty links </h2>
  
<a class="message-action bp-tooltip" data-bptooltip="Star this message" aria-label="Star this messaage" data-status="star" data-star-nonce="fae1acf32e" data-message-id="6" href="#"><span class="icon" aria-hidden="true">&#xf006;</span></a>
  
<a class="message-action bp-tooltip" data-bptooltip="I love this" aria-label="I love this" data-status="heart" data-star-nonce="fae1acf32e" data-message-id="6" href="#"><span class="icon" aria-hidden="true">&#xf08a;</span></a>
  
<a class="message-action bp-tooltip" data-bptooltip="Add Comment" aria-label="Add comment" data-status="comment" data-star-nonce="fae1acf32e" data-message-id="6" href="#"><span class="icon" aria-hidden="true">&#xf075;</span></a>

<a class="message-action bp-tooltip" data-bptooltip="Reply" aria-label="Reply" data-status="reply" data-star-nonce="fae1acf32e" data-message-id="6" href="#"><span class="icon" aria-hidden="true">&#xf112;</span></a>

<a class="message-action bp-tooltip" data-bptooltip="Delete" aria-label="Delete this messaage" data-status="remove" data-star-nonce="fae1acf32e" data-message-id="6" href="#"><span class="icon" aria-hidden="true">&#xf00d;</span></a>

<h2>B. SVG Icons in empty links</h2>

<a class="svg-icon bp-tooltip" data-bptooltip="Star this message" aria-label="Star this messaage" data-status="star" data-star-nonce="fae1acf32e" data-message-id="6" href="#">
<svg aria-hidden="true" id="i-star" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M16 2 L20 12 30 12 22 19 25 30 16 23 7 30 10 19 2 12 12 12 Z" />
</svg></a>

<a class="svg-icon bp-tooltip" data-bptooltip="I love this" aria-label="I love this" data-status="heart" data-star-nonce="fae1acf32e" data-message-id="6" href="#">
<svg aria-hidden="true" id="i-heart" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M4 16 C1 12 2 6 7 4 12 2 15 6 16 8 17 6 21 2 26 4 31 6 31 12 28 16 25 20 16 28 16 28 16 28 7 20 4 16 Z" />
</svg>
</a>

<a class="svg-icon bp-tooltip" data-bptooltip="Add Comment" aria-label="Add comment" data-status="comment" data-star-nonce="fae1acf32e" data-message-id="6" href="#">
<svg aria-hidden="true" id="i-msg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M2 4 L30 4 30 22 16 22 8 29 8 22 2 22 Z" />
</svg>
</a>

<a class="svg-icon bp-tooltip" data-bptooltip="Reply" aria-label="Reply" data-status="reply" data-star-nonce="fae1acf32e" data-message-id="6" href="#">
<svg aria-hidden="true" id="i-reply" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M10 6 L3 14 10 22 M3 14 L18 14 C26 14 30 18 30 26" />
</svg>
</a>

<a class="svg-icon bp-tooltip" data-bptooltip="Delete this Message" aria-label="Delete this message" data-status="delete" data-star-nonce="fae1acf32e" data-message-id="6" href="#">
<svg aria-hidden="true" id="i-close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M2 30 L30 2 M30 30 L2 2" />
</svg>
</a>

<h2>C. Icon Fonts in Buttons</h2>

<button type="button" class="message-action bp-tooltip" data-bptooltip="Star this message" aria-label="Star this messaage" data-status="star" data-star-nonce="fae1acf32e" data-message-id="6"><span class="icon" aria-hidden="true">&#xf006;</span></button>
  
<button type="button" class="message-action bp-tooltip" data-bptooltip="I love this" aria-label="I love this" data-status="heart" data-star-nonce="fae1acf32e" data-message-id="6"><span class="icon" aria-hidden="true">&#xf08a;</span></button>
  
<button type="button" class="message-action bp-tooltip" data-bptooltip="Add Comment" aria-label="Add comment" data-status="comment" data-star-nonce="fae1acf32e" data-message-id="6"><span class="icon" aria-hidden="true">&#xf075;</span></button>

<button type="button" class="message-action bp-tooltip" data-bptooltip="Reply" aria-label="Reply" data-status="reply" data-star-nonce="fae1acf32e" data-message-id="6"><span class="icon" aria-hidden="true">&#xf112;</span></button>

<button type="button" class="message-action bp-tooltip" data-bptooltip="Delete" aria-label="Delete this messaage" data-status="remove" data-star-nonce="fae1acf32e" data-message-id="6"><span class="icon" aria-hidden="true">&#xf00d;</span></button>
  
<h2>D. SVG Icons in Buttons</h2>
                                   
<button type="button" class="bp-tooltip svg-icon" data-bptooltip="Star this message" aria-label="Star this messaage"  data-status="star" data-star-nonce="fae1acf32e" data-message-id="6">
<svg aria-hidden="true" id="i-star" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M16 2 L20 12 30 12 22 19 25 30 16 23 7 30 10 19 2 12 12 12 Z" />
</svg>
</button>

<button type="button" class="bp-tooltip svg-icon" data-bptooltip="I love this" aria-label="I love this" data-status="heart" data-star-nonce="fae1acf32e" data-message-id="6">
<svg aria-hidden="true" id="i-heart" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M4 16 C1 12 2 6 7 4 12 2 15 6 16 8 17 6 21 2 26 4 31 6 31 12 28 16 25 20 16 28 16 28 16 28 7 20 4 16 Z" />
</svg>
</button>

<button type="button" class="bp-tooltip svg-icon" data-bptooltip="Add Comment" aria-label="Add comment" data-status="comment" data-star-nonce="fae1acf32e" data-message-id="6">
<svg aria-hidden="true" id="i-msg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M2 4 L30 4 30 22 16 22 8 29 8 22 2 22 Z" />
</svg>
</button>

<button type="button" class="bp-tooltip svg-icon" data-bptooltip="Reply" aria-label="Reply" data-status="reply" data-star-nonce="fae1acf32e" data-message-id="6">
<svg aria-hidden="true" id="i-reply" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M10 6 L3 14 10 22 M3 14 L18 14 C26 14 30 18 30 26" />
</svg>
</button>

<button type="button" class="bp-tooltip svg-icon" data-bptooltip="Delete this message" aria-label="Delete this messaage" data-status="delete" data-star-nonce="fae1acf32e" data-message-id="6">
<svg aria-hidden="true" id="i-close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="10%">
    <path d="M2 30 L30 2 M30 30 L2 2" />
</svg>
</button>

<h2>E. Additional Text</h2>

<p>Link: Admin created the group BP Nouveau <a href="#link-to-page" class="bp-tooltip" data-bptooltip="View Discussion" aria-label="View Discussion"><span class="time-since">1 week, 3 days ago</a></p>
<p>Link: <a href="#link-to-page" class="bp-tooltip rss" data-bptooltip="RSS Feed link" aria-label="RSS Feed link">RSS</a></p>
<button type="button" class="bp-tooltip button confirm" href="#link-to-page" data-bptooltip="Delete Conversation" aria-label="Delete Conversation">Delete</button>

<h2>F. Floated Avatars - img div container floated</h2>
<div class="avatar-block">
	<div class="item-avatar">
		<a href="https://profiles.wordpress.org/johnjamesjacoby" class="bp-tooltip" data-bptooltip="John James Jacoby"><img alt="Profile Photo of John James Jacoby" src="//www.gravatar.com/avatar/7a2644fb53ae2f7bfd7143b504af396c?s=100"></a>
	</div>
	<div class="item-avatar">
		<a href="https://profiles.wordpress.org/boonebgorges" class="bp-tooltip" data-bptooltip="Boone B. Gorges"><img alt="Profile Photo of Boone B. Gorges" src="//www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c?s=100"></a>
	</div>
	<div class="item-avatar">
		<a href="https://profiles.wordpress.org/djpaul" class="bp-tooltip" data-bptooltip="Paul Gibbs"><img alt="Profile Photo of Paul Gibbs" src="//www.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=100"></a>
	</div>
	<div class="item-avatar">
		<a href="https://profiles.wordpress.org/r-a-y" class="bp-tooltip" data-bptooltip="Ray"><img alt="Profile Photo of Ray" src="//www.gravatar.com/avatar/3bfa556a62b5bfac1012b6ba5f42ebfa?s=100"></a>
	</div>
	<div class="item-avatar">
		<a href="ttps://profiles.wordpress.org/imath" class="bp-tooltip" data-bptooltip="Mathieu Viet"><img alt="Profile Photo of Mathieu Viet" src="//www.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=100"></a>
	</div>
	<div class="item-avatar">
		<a href="https://profiles.wordpress.org/mercime" class="bp-tooltip" data-bptooltip="Mercime"><img alt="Profile Photo of Mercime" src="//www.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=100"></a>
	</div>
	<div class="item-avatar">
		<a href="https://profiles.wordpress.org/dcavins" class="bp-tooltip" data-bptooltip="David Cavins"><img alt="Profile Photo of David Cavins" src="//www.gravatar.com/avatar/a5fa7e83d59cb45ebb616235a176595a?s=100"></a>
	</div>
	<div class="item-avatar">
		<a href="https://profiles.wordpress.org/tw2113" class="bp-tooltip" data-bptooltip="Michael Beckwith"><img alt="Profile Photo of Michael Beckwith" src="//www.gravatar.com/avatar/a5d7c934621fa1c025b83ee79bc62366?s=100"></a>
	</div>
	<div class="item-avatar">
		<a href="https://profiles.wordpress.org/hnla" class="bp-tooltip" data-bptooltip="Hugo Ashmore"><img alt="Profile Photo of Hugo Ashmore" src="//www.gravatar.com/avatar/3860c955aa3f79f13b92826ae47d07fe?s=100"></a>
	</div>
  
</div>

<div class="clear"></div>
  
<h2>G. Floated Avatars - img.avatar floated left</h2>
<div class="avatar-block">
	<div class="item-avatar-float">
		<a href="https://profiles.wordpress.org/johnjamesjacoby" class="bp-tooltip" data-bptooltip="John James Jacoby"><img alt="Profile Photo of John James Jacoby" class="avatar" src="//www.gravatar.com/avatar/7a2644fb53ae2f7bfd7143b504af396c?s=100"></a>
	</div>
	<div class="item-avatar-float">
		<a href="https://profiles.wordpress.org/boonebgorges" class="bp-tooltip" data-bptooltip="Boone B. Gorges"><img alt="Profile Photo of Boone B. Gorges" class="avatar" src="//www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c?s=100"></a>
	</div>
	<div class="item-avatar-float">
		<a href="https://profiles.wordpress.org/djpaul" class="bp-tooltip" data-bptooltip="Paul Gibbs"><img alt="Profile Photo of Paul Gibbs" class="avatar" src="//www.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=100"></a>
	</div>
	<div class="item-avatar-float">
		<a href="https://profiles.wordpress.org/r-a-y" class="bp-tooltip" data-bptooltip="Ray"><img alt="Profile Photo of Ray" class="avatar" src="//www.gravatar.com/avatar/3bfa556a62b5bfac1012b6ba5f42ebfa?s=100"></a>
	</div>
	<div class="item-avatar-float">
		<a href="ttps://profiles.wordpress.org/imath" class="bp-tooltip" data-bptooltip="Mathieu Viet"><img alt="Profile Photo of Mathieu Viet" class="avatar" src="//www.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=100"></a>
	</div>
	<div class="item-avatar-float">
		<a href="https://profiles.wordpress.org/mercime" class="bp-tooltip" data-bptooltip="Mercime"><img alt="Profile Photo of Mercime" class="avatar" src="//www.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=100"></a>
	</div>
	<div class="item-avatar-float">
		<a href="https://profiles.wordpress.org/dcavins" class="bp-tooltip" data-bptooltip="David Cavins"><img alt="Profile Photo of David Cavins" class="avatar" src="//www.gravatar.com/avatar/a5fa7e83d59cb45ebb616235a176595a?s=100"></a>
	</div>
	<div class="item-avatar-float">
		<a href="https://profiles.wordpress.org/tw2113" class="bp-tooltip" data-bptooltip="Michael Beckwith"><img alt="Profile Photo of Michael Beckwith" class="avatar" src="//www.gravatar.com/avatar/a5d7c934621fa1c025b83ee79bc62366?s=100"></a>
	</div>
	<div class="item-avatar-float">
		<a href="https://profiles.wordpress.org/hnla" class="bp-tooltip" data-bptooltip="Hugo Ashmore"><img alt="Profile Photo of Hugo Ashmore" class="avatar" src="//www.gravatar.com/avatar/3860c955aa3f79f13b92826ae47d07fe?s=100"></a>
	</div>
  
</div>
<div class="clear"></div>
<p> JS needed for mobile/touchscreens only. Tooltip shows up on touch start, but it does not disappear on touch end.</p>

</div><!-- .buddypress-wrap -->

              
            
!

CSS

              
                body {
  background-color: #eee;
  font-family: "Lucida Grande", "Lucida Sans", Tahoma, sans-serif;
}

.buddypress-wrap {
  background-color: #fafafa;
  margin: 3em auto;
  padding: 2em 4em;
  width: 500px;
}

h1  {
  color: #990099;
}

h2 {
  font-weight: normal;
  margin: 2em auto 1em;
}

.clear {
  clear: both;
  display: block;
  
}

a {
  color: #990099;
  text-decoration: none;
}

a span.time-since,
a.rss {
  text-decoration: underline;
}

a.message-action {
  height: 20px;
  margin-right: 30px;
  width: 20px;
}

.message-action .icon {
  font-family: FontAwesome;
}

.message-action,
.svg-icon {
  margin-bottom: 30px;
  margin-right: 30px;
}

.svg-icon svg {
  height: 15px;
  width: 15px;
}

button {
  background-color: #eee; 
  border: none;
  color: #000;
  padding: 7px 15px;
  text-align: center;
  text-decoration: none;
}

button:hover,
button:focus {
  background-color: #990099; 
  color: white;
}

.avatar-block {
  width: 400px;
}

.item-avatar {
  float: left;
  height: 100px;
  margin: 0 30px 30px 0;
  width: 100px;
}

.item-avatar img {
  border: 3px solid #555;
  border-radius: 50%;  
}

.bp-tooltip {
    position: relative;
}

.bp-tooltip::after {
    position: absolute;
    z-index: 1000000;
    display: none;
    padding: 5px 8px;
    font: normal normal 11px/1.5 -apple-system,  BlinkMacSystemFont,  "Segoe UI",  Helvetica,  Arial,  sans-serif,  "Apple Color Emoji",  "Segoe UI Emoji",  "Segoe UI Symbol";
    -webkit-font-smoothing: subpixel-antialiased;
    color: #fff;
    text-align: center;
    text-decoration: none;
    text-shadow: none;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: break-word;
    white-space: pre;
    pointer-events: none;
    content: attr(aria-label);
    background: rgba(0, 0, 0, 0.8);
    border-radius: 3px;
    opacity: 0;
}
.bp-tooltip::before {
    position: absolute;
    z-index: 1000001;
    display: none;
    width: 0;
    height: 0;
    color: rgba(0, 0, 0, 0.8);
    pointer-events: none;
    content: "";
    border: 5px solid transparent;
    opacity: 0;
}
@-webkit-keyframes tooltip-appear {
    from {
    opacity: 0;
}
to {
    opacity: 1;
}
}
@keyframes tooltip-appear {
    from {
    opacity: 0;
}
to {
    opacity: 1;
}
}
.bp-tooltip:hover::before, 
.bp-tooltip:hover::after, 
.bp-tooltip:active::before, 
.bp-tooltip:active::after, 
.bp-tooltip:focus::before, 
.bp-tooltip:focus::after {
    display: inline-block;
    text-decoration: none;
    -webkit-animation-name: tooltip-appear;
    animation-name: tooltip-appear;
    -webkit-animation-duration: 0.1s;
    animation-duration: 0.1s;
    -webkit-animation-fill-mode: forwards;
    animation-fill-mode: forwards;
    -webkit-animation-timing-function: ease-in;
    animation-timing-function: ease-in;
    -webkit-animation-delay: 0.4s;
    animation-delay: 0.4s;
}
.bp-tooltip-no-delay:hover::before, 
.bp-tooltip-no-delay:hover::after,
.bp-tooltip-no-delay:active::before, 
.bp-tooltip-no-delay:active::after, 
.bp-tooltip-no-delay:focus::before, 
.bp-tooltip-no-delay:focus::after {
    opacity: 1;
    -webkit-animation: none;
    animation: none;
}
.bp-tooltip-multiline:hover::after, 
.bp-tooltip-multiline:active::after, 
.bp-tooltip-multiline:focus::after {
    display: table-cell;
}
.bp-tooltip-s::after, 
.bp-tooltip-se::after, 
.bp-tooltip-sw::after {
    top: 100%;
    right: 50%;
    margin-top: 5px;
}
.bp-tooltip-s::before, 
.bp-tooltip-se::before, 
.bp-tooltip-sw::before {
    top: auto;
    right: 50%;
    bottom: -5px;
    margin-right: -5px;
    border-bottom-color: rgba(0, 0, 0, 0.8);
}
.bp-tooltip-se::after {
    right: auto;
    left: 50%;
    margin-left: -15px;
}
.bp-tooltip-sw::after {
    margin-right: -15px;
}
.bp-tooltip-n::after, 
.bp-tooltip-ne::after, 
.bp-tooltip-nw::after {
    right: 50%;
    bottom: 100%;
    margin-bottom: 5px;
}
.bp-tooltip-n::before, 
.bp-tooltip-ne::before, 
.bp-tooltip-nw::before {
    top: -5px;
    right: 50%;
    bottom: auto;
    margin-right: -5px;
    border-top-color: rgba(0, 0, 0, 0.8);
}
.bp-tooltip-ne::after {
    right: auto;
    left: 50%;
    margin-left: -15px;
}
.bp-tooltip-nw::after {
    margin-right: -15px;
}
.bp-tooltip-s::after, 
.bp-tooltip-n::after {
    -webkit-transform: translateX(50%);
    transform: translateX(50%);
}
.bp-tooltip-w::after {
    right: 100%;
    bottom: 50%;
    margin-right: 5px;
    -webkit-transform: translateY(50%);
    transform: translateY(50%);
}
.bp-tooltip-w::before {
    top: 50%;
    bottom: 50%;
    left: -5px;
    margin-top: -5px;
    border-left-color: rgba(0, 0, 0, 0.8);
}
.bp-tooltip-e::after {
    bottom: 50%;
    left: 100%;
    margin-left: 5px;
    -webkit-transform: translateY(50%);
    transform: translateY(50%);
}
.bp-tooltip-e::before {
    top: 50%;
    right: -5px;
    bottom: 50%;
    margin-top: -5px;
    border-right-color: rgba(0, 0, 0, 0.8);
}
.bp-tooltip-multiline::after {
    width: -webkit-max-content;
    width: -moz-max-content;
    width: max-content;
    max-width: 250px;
    word-break: break-word;
    word-wrap: normal;
    white-space: pre-line;
    border-collapse: separate;
}
.bp-tooltip-multiline.bp-tooltip-s::after, 
.bp-tooltip-multiline.bp-tooltip-n::after {
    right: auto;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
}
.bp-tooltip-multiline.bp-tooltip-w::after, 
.bp-tooltip-multiline.bp-tooltip-e::after {
    right: 100%}
              
            
!

JS

              
                /* Progressive enhancement. JS for mobile touch only. Tooltip shows up on touch start, but does disappear on touch end. */





              
            
!
999px

Console