$tooltip-color: transparentize($dark-gray, 0.1); $tooltip-placement: top; // "top" or "bottom" @mixin tooltip($position) { position: relative; $opposite-position: bottom; @if ($position == top) { $opposite-position: bottom; } @else if ($position == bottom) { $opposite-position: top; } &:hover { .tooltip { opacity: 1; visibility: visible; } } .tooltip { background-color: $tooltip-color; box-sizing: border-box; color: white; font-weight: normal; opacity: 0; padding: 0.5em 1em; border-radius: $base-border-radius; position: absolute; text-align: center; text-overflow: ellipsis; text-shadow: 0 1px 0 darken(rgb(80,80,80), 4%); text-transform: none; transition: all 0.15s linear; white-space: nowrap; visibility: hidden; width: 200px; z-index: 10; #{$position}: -50px; left: 50%; margin-left: -(200px/2); &:before, &:after { display: block; pointer-events: none; position: absolute; width: 0; height: 0; content: ''; border: 8px solid transparent; } &:before { top: auto; bottom: -18px; left: auto; right: auto; left: 50%; margin-left: -(8px + 1); } &:after { border-#{$position}-color: $tooltip-color; $position: auto; #{$opposite-position}: -16px; left: auto; right: auto; left: 50%; margin-left: -8px; } } } a.tooltip-item { @include button(simple, lighten($light-gray, 10)); @include tooltip($tooltip-placement); font-size: $base-font-size; }