当前位置:网站首页>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>
边栏推荐
- Integrate CDN to create the ultimate service experience for customers!
- Svg code snippet of loading animation
- How do the defi protocols perform under this round of stress test?
- There is 404 in the laravel visit, except the home page is redirected; Index php
- Eyeshot 2022 Released
- Introduction to the hardest core PWN in the whole network_ Graphic analysis
- 2021-10-24
- Flex flexible layout for mobile terminal page production
- great! Auto like, I use pyautogui!
- 执行SQL响应比较慢,你有哪些排查思路?
猜你喜欢

Why is the TCP handshake just 3 times?

Two hours to take you into the software testing industry (with a full set of software testing learning routes)

The SQL response is slow. What are your troubleshooting ideas?

《QDebug 2022年6月》

Vscade setting clang format

Svg code snippet of loading animation

How to use the Magic pig system reinstallation master

Student achievement management system based on SSH

How to download and use Xiaobai one click reload on the official website

Why does the SQL statement hit the index faster than it does not?
随机推荐
Precise delay based on Cortex-M3 and M4 (systick delay of system timer can be used for STM32, aducm4050, etc.)
Laravel's little knowledge
初识 Flutter 的绘图组件 — CustomPaint
Successfully solved: selenium common. exceptions. TimeoutException: Message: timeout: Timed out receiving message from
In depth understanding of line height and vertical align
Attack and defense world web baby Web
Implementation of websocket long connection by workman under laravel
Huawei Hongmeng development lesson 4
Visual studio 2022 interface beautification tutorial
基于SSH实现的学生成绩管理系统
OOP stack class template (template +ds)
Méthode de récupération des données d'ouverture du disque dur à l'état solide
Response (XI)
Working principle of asemi three-phase rectifier bridge
MySQL concept and operation (III)
Leader: who can use redis expired monitoring to close orders and get out of here!
Activereportsjs V3.0 comes on stage
OpenSea PHP开发包
以太网是什么要怎么连接电脑
PHP calls map API