Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ToolTip with Delay/ToolTipVideo.mp4
Binary file not shown.
68 changes: 68 additions & 0 deletions ToolTip with Delay/tooltip.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Reset */
body {
font-family: sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #fafafa;
}

.tooltip-container {
position: relative;
display: inline-block;
}

/* Target element */
.tooltip-target {
padding: 10px 20px;
border: none;
background: #0077cc;
color: white;
border-radius: 5px;
cursor: pointer;
}

/* Tooltip text */
.tooltip-text {
visibility: hidden;
opacity: 0;
width: max-content;
background: #333;
color: #fff;
text-align: center;
padding: 6px 12px;
border-radius: 4px;

position: absolute;
bottom: 125%; /* above the button */
left: 50%;
transform: translateX(-50%);

white-space: nowrap;
pointer-events: none;

/* Animation */
transition: opacity 0.3s ease;
transition-delay: 0s; /* will be updated on hover */
}

/* Tooltip arrow */
.tooltip-text::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #333 transparent transparent transparent;
}

/* Show tooltip with delay */
.tooltip-target:hover + .tooltip-text,
.tooltip-target:focus + .tooltip-text {
visibility: visible;
opacity: 1;
transition-delay: 0.5s; /* delay before showing */
}
17 changes: 17 additions & 0 deletions ToolTip with Delay/tooltip.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS-only Tooltip with Delay</title>
<link rel="stylesheet" href="tooltip.css">
</head>
<body>

<div class="tooltip-container">
<button class="tooltip-target">Hover me</button>
<span class="tooltip-text">I am a tooltip with a delay!</span>
</div>

</body>
</html>