Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

สร้าง Tooltip ด้วย CSS

Tooltip คือข้อความเล็กๆ ที่แสดงเมื่อผู้ใช้วางเมาส์เหนือข้อความ ใช้เพื่อให้ข้อมูลเพิ่มเติมช่วยให้ผู้ใช้เข้าใจง่ายขึ้น

ตัวอย่าง

ลองรันโค้ดด้านล่างเพื่อเรียนรู้การสร้าง tooltip

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