<div class="container">
  <h1>CSS Directional c-tooltips</h1>
  <div class="demo">
    <p><code>data-c-tooltip</code> <a href="#" data-c-tooltip="I’m the c-tooltip text.">Hover me!</a></p>
    <p><code>[tooltip-position='top'] </code> <a href="#" class="c-tooltip-top" data-c-tooltip="I’m the c-tooltip text.">Hover me!</a></p>
    <p><code>[tooltip-position='right'] </code> <a href="#" tooltip-position='right' data-c-tooltip="I’m the c-tooltip text.">Hover me!</a></p>
    <p><code>[tooltip-position='bottom'] </code> <a href="#" tooltip-position='bottom' data-c-tooltip="I’m the c-tooltip text.">Hover me!</a></p>
    <p><a href="#" tooltip-position='left' data-c-tooltip="I’m the c-tooltip text.">Hover me!</a> <code>[tooltip-position='left'] </code></p>
  </div>
</div>
a:hover {
  text-decoration: none;
}
header,
.demo,
.demo p {
  margin: 4em 0;
  text-align: center;
}
/**
 * c-tooltip Styles
 */
/* Base styles for the element that has a c-tooltip */
[data-c-tooltip] {
  position: relative;
  cursor: pointer;
}
/* Base styles for the entire c-tooltip */
[data-c-tooltip]:before,
[data-c-tooltip]:after {
  position: absolute;
  visibility: hidden;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
  opacity: 0;
  -webkit-transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out, -webkit-transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
  -moz-transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out, -moz-transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out, transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
  -webkit-transform: translate3d(0, 0, 0);
  -moz-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  pointer-events: none;
}
/* Show the entire c-tooltip on hover and focus */
[data-c-tooltip]:hover:before,
[data-c-tooltip]:hover:after,
[data-c-tooltip]:focus:before,
[data-c-tooltip]:focus:after {
  visibility: visible;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
  opacity: 1;
}
/* Base styles for the c-tooltip's directional arrow */
[data-c-tooltip]:before {
  z-index: 1001;
  border: 6px solid transparent;
  background: transparent;
  content: "";
}
/* Base styles for the c-tooltip's content area */
[data-c-tooltip]:after {
  z-index: 1000;
  padding: 8px;
  width: 160px;
  background-color: #000;
  background-color: rgba(51, 51, 51, 0.9);
  color: #fff;
  content: attr(data-c-tooltip);
  font-size: 14px;
  line-height: 1.2;
}
/* Directions */
/* Top (default) */
[data-c-tooltip]:before,
[data-c-tooltip]:after {
  bottom: 100%;
  left: 50%;
}
[data-c-tooltip]:before{
  margin-left: -6px;
  margin-bottom: -12px;
  border-top-color: #000;
  border-top-color: rgba(51, 51, 51, 0.9);
}
/* Horizontally align top/bottom c-tooltips */
[data-c-tooltip]:after {
  margin-left: -80px;
}
[data-c-tooltip]:hover:before,
[data-c-tooltip]:hover:after,
[data-c-tooltip]:focus:before,
[data-c-tooltip]:focus:after{
  -webkit-transform: translateY(-12px);
  -moz-transform: translateY(-12px);
  transform: translateY(-12px);
}

/* Left */
[tooltip-position='left']:before,
[tooltip-position='left']:after {
  right: 100%;
  bottom: 50%;
  left: auto;
}
[tooltip-position='left']:before {
  margin-left: 0;
  margin-right: -12px;
  margin-bottom: 0;
  border-top-color: transparent;
  border-left-color: #000;
  border-left-color: rgba(51, 51, 51, 0.9);
}
[tooltip-position='left']:hover:before,
[tooltip-position='left']:hover:after,
[tooltip-position='left']:focus:before,
[tooltip-position='left']:focus:after {
  -webkit-transform: translateX(-12px);
  -moz-transform: translateX(-12px);
  transform: translateX(-12px);
}
/* Bottom */
[tooltip-position='bottom']:before,
[tooltip-position='bottom']:after {
  top: 100%;
  bottom: auto;
  left: 50%;
}
[tooltip-position='bottom']:before {
  margin-top: -12px;
  margin-bottom: 0;
  border-top-color: transparent;
  border-bottom-color: #000;
  border-bottom-color: rgba(51, 51, 51, 0.9);
}
[tooltip-position='bottom']:hover:before,
[tooltip-position='bottom']:hover:after,
[tooltip-position='bottom']:focus:before,
[tooltip-position='bottom']:focus:after {
  -webkit-transform: translateY(12px);
  -moz-transform: translateY(12px);
  transform: translateY(12px);
}
/* Right */
[tooltip-position='right']:before,
[tooltip-position='right']:after {
  bottom: 50%;
  left: 100%;
}
[tooltip-position='right']:before {
  margin-bottom: 0;
  margin-left: -12px;
  border-top-color: transparent;
  border-right-color: #000;
  border-right-color: rgba(51, 51, 51, 0.9);
}
[tooltip-position='right']:hover:before,
[tooltip-position='right']:hover:after,
[tooltip-position='right']:focus:before,
[tooltip-position='right']:focus:after {
  -webkit-transform: translateX(12px);
  -moz-transform: translateX(12px);
  transform: translateX(12px);
}
/* Move directional arrows down a bit for left/right c-tooltips */
[tooltip-position='left']:before,
[tooltip-position='right']:before {
  top: 3px;
}
/* Vertically center c-tooltip content for left/right c-tooltips */
[tooltip-position='left']:after,
[tooltip-position='right']:after {
  margin-left: 0;
  margin-bottom: -16px;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.