Programming language/HTML & CSS
tooltip( 말풍선 ) CSS (2)
hello-world
2018. 10. 17. 17:02
728x90
반응형
tooltip( 말풍선 ) CSS
HTML Element의 속성 값을 활용하여 별도의 js없이 HTML/CSS로만 tooltip( 말풍선 ) 만들기.
- 이전 포스트의 "tooltip( 말풍선 ) CSS (1)" 보단 좀더 활용도가 있을 듯 싶다.
HTML
<!-- 버튼 엘리먼트 -->
<a href="#" class="bt-tooltip" data-title="댓글달기">댓글달기</a>
CSS
/* 툴팁 balloon */
.bt-tooltip {
position: relative;
display:inline-block;
}
.bt-tooltip:hover[data-title]:before,
.bt-tooltip:hover[data-title]:after {
visibility: visible;
pointer-events: auto
}
.bt-tooltip[data-title]:before,
.bt-tooltip[data-title]:after {
pointer-events: none;
visibility: hidden;
}
.bt-tooltip[data-title]:before{
content: '';
position: absolute;
top: auto;
right: auto;
bottom: 100%;
left: 50%;
font-size: 1rem;
width: .71428571em;
height: .71428571em;
background: #fff;
-webkit-transform: rotate(45deg) translateX(-50%);
transform: rotate(45deg) translateX(-50%);
z-index: 2;
-webkit-box-shadow: 1px 1px 0 0 #bababc;
box-shadow: 1px 1px 0 0 #bababc;
}
.bt-tooltip[data-title]:after {
content: attr(data-title);
position: absolute;
top: auto;
right: auto;
left: 50%;
bottom: 100%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
margin-bottom: .5em;
text-transform: none;
text-align: left;
white-space: nowrap;
font-size: 1rem;
border: 1px solid #d4d4d5;
line-height: 1.4285em;
max-width: none;
background: #fff;
padding: .633em 1em;
font-weight: 400;
font-style: normal;
color: rgba(0,0,0,.87);
border-radius: .48571429rem;
-webkit-box-shadow: 0 2px 4px 0 rgba(34,36,38,.12), 0 2px 10px 0 rgba(34,36,38,.15);
box-shadow: 0 2px 4px 0 rgba(34,36,38,.12), 0 2px 10px 0 rgba(34,36,38,.15);
z-index: 1;
}
728x90
반응형