当前位置:网站首页>Drag modal box
Drag modal box
2022-06-25 05:03:00 【Dai Sensen】
<!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; } .login_bg {
display: none; position: absolute; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); z-index: 1; } h1 {
text-align: center; } .login_box {
display: none; position: fixed; top: 50%; left: 50%; transform: translateX(-50%) translateY(-50%); text-align: center; width: 400px; height: 200px; background-color: pink; z-index: 2; } </style>
</head>
<body>
<div id='bg' class="login_bg"></div>
<h1> Click to pop up the login box </h1>
<div class="login_box">
<h3> Member login </h3>
<div> user name :<input type="text" value=" Please enter a user name "></div>
<div> password :<input type="password" value=" Please enter the login password "></div>
<button class="link"> Login member </button>
<button class="close"> close </button>
<script> var login_box = document.querySelector('.login_box'); var mask = document.querySelector('.login_bg'); var h1 = document.querySelector('h1'); var close = document.querySelector('.close'); var link = document.querySelector('.link'); var h3 = document.querySelector('h3'); h1.addEventListener('click', function() {
login_box.style.display = 'block'; mask.style.display = 'block'; }); close.addEventListener('click', function() {
login_box.style.display = 'none'; mask.style.display = 'none'; }); // Get the mouse coordinates in the box h3.addEventListener('mousedown', function(e) {
var x = e.pageX - login_box.offsetLeft; var y = e.pageY - login_box.offsetTop; // Coordinates from the border to the edge of the document document.addEventListener('mousemove', fn); function fn(e) {
login_box.style.left = e.pageX - x + 'px'; login_box.style.top = e.pageY - y + 'px'; } // Mouse movement event removal document.addEventListener('mouseup', function() {
document.removeEventListener('mousemove', fn); }); }); </script>
</div>
</body>
</html>
边栏推荐
- 基于Cortex-M3、M4的精准延时(系统定时器SysTick延时,可用于STM32、ADuCM4050等)
- Redis (17)
- Codeforces Round #802 (Div. 2) C D
- Region of Halcon: generation of multiple regions (3)
- parallel recovery slave next change & parallel recovery push change
- Precise delay based on Cortex-M3 and M4 (systick delay of system timer can be used for STM32, aducm4050, etc.)
- Mysql interactive_ Timeout and wait_ Timeout differences
- OOP vector addition and subtraction (friend + copy construction)
- Why is the TCP handshake just 3 times?
- DMA double buffer mode of stm32
猜你喜欢

SQL lab range explanation

buuctf(pwn)

Visual studio 2022 interface beautification tutorial

Méthode de récupération des données d'ouverture du disque dur à l'état solide

Detailed summary of float

Read the general components of antd source code

Virtual honeypot Honeyd installation and deployment

小白一键重装官网下载使用方法

At the age of 30, I began to learn programming by myself. Is it still time for me to have difficulties at home?

leetcode1221. Split balance string
随机推荐
ORA-00800: soft external error
绝了!自动点赞,我用 PyAutoGUI!
EL & JSTL (XIII)
Separation of storage and computing in Dahua cloud native database
Laravel Vonage SMS sending
Successfully solved: selenium common. exceptions. TimeoutException: Message: timeout: Timed out receiving message from
PHP calls map API
Student achievement management system based on SSH
Flex flexible layout for mobile terminal page production
Swift rapid development
Database query optimization method
Records of ros2/dds/qos/ topics
February 19 CTF exercise
以太网是什么要怎么连接电脑
win11蓝牙无法连接怎么办?win11蓝牙无法连接的解决方法
Specific operations for uploading pictures in PHP
OLAP analysis engine kylin4.0
Matlab notes
Redis (17)
Kotlin Compose 监听软键盘 点击enter提交事件