Tooltip Hover
ホバーで上に表示されるツールチップ。
HTML
<div class="tip-wrap"> <button class="tip-trigger">Hover me</button> <div class="tip-box">This is a tooltip</div> </div>
CSS
.tip-wrap {
position: relative;
display: inline-block;
}
.tip-trigger {
padding: 8px 20px;
background: #fff;
border: 1px solid #eee;
border-radius: 6px;
font-size: 13px;
font-weight: 500;
font-family: inherit;
cursor: pointer;
color: #1a1a1a;
}
.tip-box {
position: absolute;
bottom: calc(100% + 8px);
left: 50%;
transform: translateX(-50%) translateY(4px);
padding: 6px 12px;
background: #1a1a1a;
color: #fff;
border-radius: 6px;
font-size: 12px;
font-weight: 500;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: all .2s cubic-bezier(.16,1,.3,1);
}
.tip-box::after {
content: '';
position: absolute;
top: 100%; left: 50%;
transform: translateX(-50%);
border: 4px solid transparent;
border-top-color: #1a1a1a;
}
.tip-wrap:hover .tip-box {
opacity: 1;
transform: translateX(-50%) translateY(0);
}