Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>List with Tooltips</title> <style> /* ========================================================================== Styles for Demo Preview Only ========================================================================== */ body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: #f1f5f9; color: #334155; margin: 0; padding: 2rem; display: flex; justify-content: center; } /* ========================================================================== List with Tooltips Component Styles - Copy from here ========================================================================== */ .tooltip-list-template { --tooltip-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --tooltip-primary-text-color: #1e293b; --tooltip-bg-color: #ffffff; --tooltip-border-color: #e2e8f0; --tooltip-color: #ffffff; --tooltip-box-bg: #1e293b; --tooltip-transition-speed: 0.2s; font-family: var(--tooltip-font-family); color: var(--tooltip-primary-text-color); width: 100%; max-width: 600px; background-color: var(--tooltip-bg-color); border: 1px solid var(--tooltip-border-color); border-radius: .5rem; padding: 2rem; } .tooltip-list-template *, .tooltip-list-template *::before, .tooltip-list-template *::after { box-sizing: border-box; } .tooltip-list-template .list-header { text-align: center; margin-bottom: 2rem; } .tooltip-list-template .list-header h2 { font-size: 1.75rem; margin: 0; } .ingredient-list { list-style: disc; padding-left: 1.5rem; margin: 0; } .tooltip-item { padding: .25rem 0; position: relative; /* This is crucial for positioning the tooltip */ border-bottom: 1px dashed #cbd5e1; cursor: help; } /* The tooltip box */ .tooltip-item::before { content: attr(data-tooltip); /* Get content from the data-attribute */ position: absolute; bottom: 100%; /* Position above the element */ left: 50%; transform: translateX(-50%); background-color: var(--tooltip-box-bg); color: var(--tooltip-color); padding: 0.5rem 0.75rem; border-radius: .25rem; font-size: .875rem; white-space: nowrap; opacity: 0; /* Hidden by default */ pointer-events: none; /* Prevents the tooltip from interfering with the mouse */ margin-bottom: 10px; /* Space between tooltip and item */ transition: opacity var(--tooltip-transition-speed) ease-in-out; } /* The tooltip arrow */ .tooltip-item::after { content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--tooltip-box-bg); opacity: 0; /* Hidden by default */ pointer-events: none; margin-bottom: 0px; /* Space between arrow and tooltip text box */ transition: opacity var(--tooltip-transition-speed) ease-in-out; } /* Show tooltip on hover */ .tooltip-item:hover::before, .tooltip-item:hover::after { opacity: 1; } </style> </head> <body> <div class="tooltip-list-template"> <header class="list-header"> <h2>Potion of Minor Inconvenience</h2> </header> <ul class="ingredient-list"> <li>Three drops of <span class="tooltip-item" data-tooltip="The silent judgment of a nearby cat.">Feline Condescension</span>.</li> <li>A pinch of <span class="tooltip-item" data-tooltip="The one you can't quite get out of your head.">That Song You Hate</span>.</li> <li>One freshly picked <span class="tooltip-item" data-tooltip="That feeling when you walk into a room and forget why.">Moment of Forgetfulness</span>.</li> <li>A whisper of <span class="tooltip-item" data-tooltip="The tiny, imperceptible wobble of a coffee table.">Subtle Instability</span>.</li> <li>A single, preserved <span class="tooltip-item" data-tooltip="Guaranteed to occur just as you're falling asleep.">Unexplained Itch</span>.</li> </ul> </div> </body> </html>