본문 바로가기

html&css/css

tooltip, title css

반응형

기본 html의 title 기능을 css로 구현한 소스코드

html 이미지에 마우스 hover 시 툴팁이 위에 뜨도록 설정

<div class="tooltip">
    테스트용
    <img  style="vertical-align: middle"  src="/img/icon_help.png" width="18px" height="18px" >
    <span class="tooltiptext tooltip-top wd400">원하는 텍스트 작성</span>
</div>

 

 

css

.tooltip {
    position: relative;
    display: block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 250px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 5px 5px 5px;
    position: absolute;
    z-index: 1;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
}

.tooltip .tooltiptext::after {
    content: " ";
    position: absolute;
    border-style: solid;
    border-width: 5px;
}

.tooltip .tooltip-top {
    width: 250px;
    bottom: 150%;
    left: 50%;
    margin-left: -60px;
}

.tooltip .tooltip-top::after {
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-color: black transparent transparent transparent;
}

.wd400 {
    width: 400px !important;
}