最近看js高級程序設計的時候突然看到瞭contextmenu屬性,之前在做項目的時候也遇到過,用來阻止鼠標右鍵彈出,(ps:禁止別人復制),今天突然想瞭下試著用這個屬性來實現以下右鍵菜單效果。
*{padding:0;margin:0;}
.menu{display:none;position:fixed;width:125px;}
.menu ul li{
height:30px;
width:120px;
margin-top:-1px ;
line-height:30px;
border:1px solid #eee;
text-align:center;
list-style:none;
}
.menu ul li:hover{
background:#ccc;
cursor:default;
user-select: none;
}