본문 바로가기
카테고리 없음

css tooltips

by Knowledge Store In Hyunsoft 2024. 11. 21.
<style>
.tooltip-container {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.tooltip-container .tooltip-text {
    visibility: hidden;
    width: 120px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 5px;
    position: absolute;
    bottom: 125%; /* Adjust the position */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}
</style>

<div class="tooltip-container">
    Hover over me
    <div class="tooltip-text">This is a tooltip</div>
</div>
728x90

댓글