建立使用者將滑鼠懸停在帶有 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.