使用 CSS 创建工具提示

原创
ithorizon 5个月前 (10-19) 阅读数 51 #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>

以上就是使用 CSS 创建工具提示的详细内容,更多请关注IT视界其它相关文章!



热门