マウスホバーで吹き出しの形のツールチップを表示する
Result
css
.tooltip {
position : relative ;
display : inline-block ;
border-bottom : 1px dotted black ;
}
.tooltip .tooltiptext {
visibility : hidden ;
width : 150px ;
background-color : black ;
color : #fff ;
text-align : center ;
padding : 5px 0 ;
border-radius : 6px ;
position : absolute ;
font-size : 12px ;
z-index : 1 ;
margin-top : 10px ;
}
.tooltip:hover .tooltiptext {
visibility : visible ;
}
.tooltip .tooltiptext::after {
content : " " ;
position : absolute ;
bottom : 100% ;
left : 50% ;
margin-left : -5px ;
border-width : 5px ;
border-style : solid ;
border-color : transparent transparent black transparent ;
}
.tooltip .tooltiptext {
opacity : 0 ;
transition : opacity 1 s;
}
.tooltip:hover .tooltiptext {
opacity : 1 ;
}
|
html
< div class = "tooltip" >マウスを乗せると
< span class = "tooltiptext" >ツールチップが表示</ span >
</ div >
|
via
w3schools.com