创建用户将鼠标悬停在带有 CSS 的元素上时出现的工具提示


你可以尝试运行以下代码以创建鼠标悬停时可见的工具提示。使用可见性属性

示例

在线演示

<!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>

更新于:2020 年 6 月 24 日

328 次浏览

开启你的 职业生涯

通过完成课程获取认证

开始
广告
© . All rights reserved.