首页 > 其他分享 >单击键盘按键弹出窗口案例

单击键盘按键弹出窗口案例

时间:2024-08-17 11:24:54浏览次数:9  
标签:none 单击 style 键盘 querySelector 按键 document display 弹窗

如题(记录学习过程)

html文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <link rel="stylesheet" href="tc.css">
</head>
<body>
    <div class="bodybox">
        <div class="弹窗">

            <button id="关闭">&times;</button>

            <h1>弹窗</h1>
            <p>点击链接</p>
            <a href="#">链接</a>

        </div>
    </div>

    <script>
        window.addEventListener("keydown",function(e){
            var keycode = e.Code
            if (keycode = "Tab") {
                document.querySelector(".弹窗").style.display = "flex"
                document.querySelector("body").style.display = "flex"
            }
        })

        document.querySelector("#关闭").addEventListener("click",function(){
            document.querySelector(".弹窗").style.display = "none"
            document.querySelector("body").style.display = "none"
        })
    </script>
</body>
</html>

tc.css文件

*{
    padding: 0px;
    margin: 0px;
}

body{
    display: none;

    background-color: rgba(90, 90, 54, 0.1);
    width: 100%;
    height: 100%;


    z-index: 8;
}

.弹窗{
    display: none;
    align-items: center;
    flex-direction: column;
    box-sizing: border-box;
    width: 20%;
    height: 100%;
    background-color: lightblue;
    position: absolute;
    padding: 40px 40px;
    left: 0%;
    top: 0%;
    border-radius: 10px;
    overflow: scroll;

    z-index: 9;
}

.弹窗 button{
    margin: -15px -10px 0 auto;
    width: 20px;
    height: 40px;
    font-size: 30px;
    background: none;
    border: none;
    cursor: pointer;
}

.弹窗 p{
    margin: 5px 20px;
    font-size: 12px;
    color: rgb(99, 98, 98);
    transition: 0.4s
}

.弹窗 a:hover {
    scale: 0.94;
}

标签:none,单击,style,键盘,querySelector,按键,document,display,弹窗
From: https://blog.csdn.net/qq_33607094/article/details/141277838

相关文章

  • utilman.exe 是 Windows 操作系统中的一个系统工具程序,全称为 Utility Manager。它的
    utilman.exe(实用工具管理器)在Windows系统中主要用于启动辅助功能工具,但它也曾经被发现存在一些安全漏洞。这些漏洞通常利用utilman.exe的特性进行权限提升或绕过安全机制。以下是一些已知的与utilman.exe相关的公开漏洞:1. CVE-2019-0708(BlueKeep)描述:这个漏洞影响了......
  • 【Qt笔记】键盘控制Qt按钮
    目录一、前言二、初始化三、键盘移动后需要选中哪个按钮四、键盘按键处理函数五、实现效果一、前言Qt框架支持通过键盘输入来间接控制界面元素,如按钮,实现无需鼠标操作的交互方式。这通常涉及到键盘事件的监听与处理,比如监听特定的按键事件(如空格键、回车键等),并在这些......
  • STMF103VET6的按键检测
     一、按键的检测的原理   根据STMF103VET6的原理图我们可以知道按键在没有按下时I/O口的电平为低电平,按键按下时I/O的电平为高电平。因此我们只需要读取按键对应的I/O口的电平就可以判断按键。 二、示例代码 1、首要初始化两个按键的GPIO。voidKEY_Init(void)......
  • vue按键修饰符
    事件的类型有以下四类:js事件分为四类:鼠标事件:click、mouseover、dbclick、mousedown、mouseout...键盘事件:keydown、keypress、keyup..窗体事件:load、reseize、scroll...表单事件:blur、focus、input、change、select传统方式的弊端:需要了解每个数值的键码为了在必要的......
  • 解决启动redis:应用程序无法正常启动(0xc000007b)。请单击“确定”关闭应用程序。
    解决处理方法如下目录方法一......
  • 单击关闭按钮关闭模型弹出来的详细信息窗口
    一、效果展示二、html内容:三、JS内容:1.0 model.js2.0 tag.js3.0 index.js备注:......
  • 两个按键分别控制两个LED亮灭
    目录1、接线图2、实现代码main.cLED.CLED.hKey.cKey.h 1、接线图2、实现代码main.c#include"stm32f10x.h"//Deviceheader#include"Delay.h"#include"LED.h"#include"Key.h"uint8_tKeyNum;intmain(void){......
  • Delphi打开软键盘osk.exe
    开发环境DelphiXE11.3UnitunitUnit1;interfaceusesWinapi.Windows,Winapi.Messages,System.SysUtils,System.Variants,System.Classes,Vcl.Graphics,Vcl.Controls,Vcl.Forms,Vcl.Dialogs,Vcl.StdCtrls,winapi.ShellAPI,ShlObj,TLHelp32;typeTForm1......
  • Python mido 未检测到 Raspberry Pi 中的键盘输入
    我有一个简单的python代码,它通过连接到PC的USB从音乐键盘获取MIDI信号,然后将命令发送到Arduino板以写入其数字输出。这工作得很好,没有任何问题。我尝试将相同的代码迁移到RaspberryPi,并进行一些特定于Pi的修改。我的代码如下:importpygameimportmidoimportr......
  • 【Unity XR Input 获取Quest和Pico各个按键状态,按下、抬起、按下中】
    usingSystem;usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.XR;usingQFramework;///<summary>///提供各种输入事件///</summary>publicclassInputEvent:MonoSingleton<InputEvent>{//*************输入设别***********......