小智 6
要切换工具提示,您可以使用复选框的 :checked 伪类。
.tooltip {
position: relative;
border-bottom: 1px dotted black;
}
.tooltip span {
visibility: hidden;
width: 10em;
background-color: #000;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 9;
top: -1em;
left: 100%;
margin-left:1em;
opacity: 0;
transition: opacity 1s;
}
.tooltip span::after {
content: "";
position: absolute;
top: 1.5em;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
.tooltip input {
display:none;
}
.tooltip input:checked+span {
visibility: visible;
opacity: 1;
}Run Code Online (Sandbox Code Playgroud)
<p>Hello <label class="tooltip">world<input type="checkbox"><span>and this is the tooltip text displayed on click.</span></label>! I am greeting you.<p>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26445 次 |
| 最近记录: |