使用 CSS 创建工具提示
cssweb developmentfront end technology更新于 2025/6/21 13:32:17
当用户将鼠标光标移动到文本上时,工具提示就会显示。您可以在其中添加信息,以便用户轻松理解。
示例
您可以尝试运行以下代码来了解如何创建工具提示 −
<!DOCTYPE html>
<html>
<style>
#mytooltip #mytext {
visibility: hidden;
width: 100px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 3px;
padding: 10px 0;
position: absolute;
z-index: 1;
}
#mytooltip:hover #mytext {
visibility: visible;
}
</style>
<body>
<div id = "mytooltip">Hover the mouse over me
<p id = "mytext">My Tooltip text</p>
</div>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

