右项选项卡(示例)

32 篇文章 0 订阅
13 篇文章 0 订阅

现模拟win11的右项选项卡

 直接上代码

<!--
 * @Author: RealRoad1083425287@qq.com
 * @Date: 2023-03-13 20:11:10
 * @LastEditors: Mei
 * @LastEditTime: 2023-03-14 08:58:53
 * @FilePath: \vscode\右键选项卡.html
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        /* #box{
            
        } */
        ul{
            list-style: none;
            display: none;
            position: absolute;
            width: 200px;
            height: 200px;
            border: 2px solid rgb(231,237,243);
            background: rgb(231,237,243);
            border-radius: 5px;
            /* display: ; */
            /* padding-left: 15px; */
            /* line-height: 20px;
            text-align: left; */
        }
        ul li{
            padding-top: 4px;
            border-left: 15px;
            /* line-height: 20px;
            text-align: left; */
        }
        ul img{
            width: 20px;
            height: 20px;
        }
        ul li:hover{
            background: rgb(221,226,230);
        }
        /* ul li span{
            width: 100%;
            height: 100%;
            text-align: right;
        } */
        /* #duiqi{
            width: 100%;
            height: 100%;
            text-align:justify;
        } */
        .test{
            display: inline-block;
            text-align: right;
            margin-left: 35px;
            font-size: 12px;
        }
        .test1{
            display: inline-block;
            text-align: right;
            margin-left: 105px;
            font-size: 12px;
        }
        .test2{
            display: inline-block;
            text-align: right;
            margin-left: 135px;
            font-size: 12px;
        }
        .test3{
            display: inline-block;
            text-align: right;
            margin-left: 138px;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <ul id="box">
        <li class="check">查看<div class="test3">></div></li>
        <li class="order">排序方式<div class="test1">></div></li>
        <li class="flash">刷新</li>
        <li class="new">新建<div class="test2">></div></li>
        <li class="screen">显示设置</li>
        <li class="human">个性化</li>
        <li class="terminal">在终端打开</li>
        <li class="more" id="duiqi">显示更多选项    <div class="test">Shift+F10</div></li>
        
    </ul>
    
    <script>
        document.addEventListener("contextmenu",function(evt){
            evt.preventDefault()
            box.style.display="block"
            var x=evt.clientX
            var y=evt.clientY
            
            if(x >= document.documentElement.clientWidth-box.
            offsetWidth)
            x=document.documentElement.clientWidth-box.offsetWidth

            if(y >= document.documentElement.clientHeight-box.
            offsetHeight)
            y=document.documentElement.clientHeight-box.
            offsetHeight

            box.style.left=x+"px"
            box.style.top=y+"px"
        })
        document.addEventListener("click",()=>{
            box.style.display="none"
        })
        box.onclick=function(evt){
            console.log("box",evt.target || evt.srcElement)
            if(evt.target.className==="check"){
                console.log(1111)
            }
        }
    </script>
</body>
</html>

查看效果:

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mez_Blog

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值