CSS自定义右键菜单
程序员文章站
2022-03-22 12:27:04
document.body.scrollTop + event.clientY - 60 }).show(); ......
<style> .menu { width: 100px; font-size: 14px; font-family: "微软雅黑"; border: 1px solid #ccc; z-index: 9999; position: absolute; display: none; background: #f2f2f2; } .menu ul { margin: 0px; padding: 0px; text-align: center; list-style-type: none; } .menu ul li { padding: 3px 0px; font-size: 12px; } .menu ul li:hover { background: #e1dddd; } .menu ul li a:link { color: #000; text-decoration: none; } </style>
<!--右侧菜单--> <div id="divmenu" class="menu"> <ul> <li onclick="expand_all()" class="pub">展开所有</li> <li onclick="collapse_all()" class="pub">合并所有</li> <li onclick="zoomin()" class="pub">画布放大</li> <li onclick="zoomout()" class="pub">画布缩小</li> <li onclick="add_node();" class="add">新增节点</li> <li onclick="openwin();" class="view">预览</li> <li onclick="update_node();" class="update">变更</li> <li onclick="add_upfile();" class="upload">上传图纸</li> <li onclick="show_selected();" class="sel">查看节点</li> <li onclick="remove_node()" class="delete">删除</li> </ul> </div>
<script type="text/javascript"> $("body").bind("contextmenu", function () {
$("#divmenu").css({ "left": document.body.scrollleft + event.clientx - 125, "top":
document.body.scrolltop + event.clienty - 60 }).show();
return false; }); </script>
上一篇: HTML5:Canvas
下一篇: 基础系列(1)-- html