簡體   English   中英

將鼠標懸停在 div 上時,在光標旁邊顯示一個菜單

[英]Show a menu next to cursor on mouse hover on div

我有一個表,當用戶將鼠標懸停在行上時,我想在該表上顯示一個按鈕組。 這是我知道我需要的。

  1. 獲取鼠標位置event.clientX and event.clientY
  2. 通過更改 css 屬性在鼠標位置旁邊顯示按鈕
  3. 當用戶離開表格行時隱藏按鈕組我不知道如何在我的光標旁邊繪制按鈕組並且按鈕功能在很大程度上依賴於我現在使用this獲得的行數據但是如果我繪制 div,我不確定我是否可以使用this 任何想法,建議,鏈接將真正appriciated。

您不需要鼠標位置,您可以通過使用 CSS :hover 屬性和 'display: hidden' 屬性來實現。

 <!DOCTYPE html> <html> <head> <style type="text/css"> table tr button { display: none; float:right } table tr:hover button { display:block } </style> </head> <body> <table border=1 width=300px> <tr><td>LINE1 <button>BUTTON1</button></td></tr> <tr><td>LINE2 <button>BUTTON2</button></td></tr> <tr><td>LINE3 <button>BUTTON3</button></td></tr> </table> </body> </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM