About this snippet

Provide helpful hints without javascript using this pure CSS tooltip. The tooltip bubble fades in and slides up when hovering over the target element, which adds a polished touch to your icons or links.

Size
1.1 KB
Uses
HTML, CSS
Loads
Nothing external
Views
352
<div style="padding: 100px; text-align: center;">
  <button class="tooltip-container">
    Hover Me
    <span class="tooltip-text">This is a CSS-only tooltip!</span>
  </button>
</div>
.tooltip-container {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  position: relative;
  display: inline-block;
  padding: 10px 20px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.tooltip-text {
  visibility: hidden;
  background-color: #1f2937;
  color: #fff;
  text-align: center;
  padding: 8px 12px;
  border-radius: 6px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s, bottom 0.3s;
  width: 140px;
  font-size: 0.85rem;
  pointer-events: none;
}
.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #1f2937 transparent transparent transparent;
}
.tooltip-container:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
  bottom: 140%;
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save