js實(shí)現(xiàn)點(diǎn)擊彈窗彈出登錄框
本文實(shí)例為大家分享了js實(shí)現(xiàn)點(diǎn)擊彈窗彈出登錄框的具體代碼,供大家參考,具體內(nèi)容如下
1 圖片預(yù)覽

2 index.html代碼
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>js點(diǎn)擊彈窗彈出登錄框代碼</title>
</head>
<body>
<style>
*{
margin:0;
padding:0;
}
button, input{
outline:none;
}
button, .login{
width:120px;
height:42px;
background:#f40;
color:#fff;
border:none;
border-radius:6px;
display: block;
margin:20px auto;
cursor: pointer;
}
.popOutBg{
width:100%;
height:100%;
position: fixed;
left:0;
top:0;
background:rgba(0,0,0,.6);
display: none;
}
.popOut{
position:fixed;
width:600px;
height:300px;
top:50%;
left:50%;
margin-top:-150px;
margin-left:-300px;
background:#fff;
border-radius:8px;
overflow: hidden;
display: none;
}
.popOut > span{
position: absolute;
right:10px;
top:0;
height:42px;
line-height:42px;
color:#000;
font-size:30px;
cursor: pointer;
}
.popOut table{
display: block;
margin:42px auto 0;
width:520px;
}
.popOut caption{
width:520px;
text-align: center;
color:#f40;
font-size:18px;
line-height:42px;
}
.popOut table tr td{
color:#666;
padding:6px;
font-size:14px;
}
.popOut table tr td:first-child{
text-align: right;
}
.inp{
width:280px;
height:30px;
line-height:30px;
border:1px solid #999;
padding:5px 10px;
color:#000;
font-size:14px;
border-radius:6px;
}
.inp:focus{
border-color:#f40;
}
@keyframes ani{
from{
transform:translateX(-100%) rotate(-60deg) scale(.5);
}
50%{
transform:translateX(0) rotate(0) scale(1);
}
90%{
transform:translateX(20px) rotate(0) scale(.8);
}
to{
transform:translateX(0) rotate(0) scale(1);
}
}
.ani{ animation:ani .5s ease-in-out;}
</style>
<button type="button">登錄</button>
<div class="popOutBg"></div>
<div class="popOut">
<span title="關(guān)閉"> x </span>
<table>
<caption>歡迎登錄本網(wǎng)站</caption>
<tr>
<td width="120">用戶(hù)名:</td>
<td><input type="text" class="inp" placeholder="請(qǐng)輸入用戶(hù)名" /></td>
</tr>
<tr>
<td>密碼:</td>
<td><input type="password" class="inp" placeholder="請(qǐng)輸入密碼" /></td>
</tr>
<tr>
<td colspan="2"><input type="button" class="login" value="登錄" /></td>
</tr>
</table>
</div>
<script type="text/javascript">
function $(param) {
if (arguments[1] == true) {
return document.querySelectorAll(param);
} else {
return document.querySelector(param);
}
}
function ani() {
$(".popOut").className = "popOut ani";
}
$("button").onclick = function() {
$(".popOut").style.display = "block";
ani();
$(".popOutBg").style.display = "block";
};
$(".popOut > span").onclick = function() {
$(".popOut").style.display = "none";
$(".popOutBg").style.display = "none";
};
$(".popOutBg").onclick = function() {
$(".popOut").style.display = "none";
$(".popOutBg").style.display = "none";
};
</script>
</body>
</html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
排序算法的javascript實(shí)現(xiàn)與講解(99js手記)
這篇文章主要介紹了排序算法的javascript實(shí)現(xiàn)與講解,需要的朋友可以參考下2014-09-09
js完美實(shí)現(xiàn)@提到好友特效(兼容各大瀏覽器)
本文給大家分享的是一則使用javascript完美實(shí)現(xiàn)兼容各大瀏覽器的@好友自動(dòng)提示的特效,是根據(jù)百度貼吧的效果模仿來(lái)的,推薦給小伙伴們,希望大家能夠喜歡。2015-03-03
微信開(kāi)發(fā)之企業(yè)付款到銀行卡接口開(kāi)發(fā)的示例代碼
這篇文章主要介紹了微信開(kāi)發(fā)之企業(yè)付款到銀行卡接口開(kāi)發(fā)的示例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-09-09
js console.log打印對(duì)像與數(shù)組用法詳解
這篇文章主要介紹了js console.log打印對(duì)像與數(shù)組用法,結(jié)合實(shí)例形式較為詳細(xì)的分析了js使用console.log實(shí)現(xiàn)打印對(duì)象與數(shù)組的具體實(shí)現(xiàn)步驟與相關(guān)技巧,需要的朋友可以參考下2016-01-01
js實(shí)現(xiàn)列表循環(huán)滾動(dòng)
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)列表循環(huán)滾動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-07-07
Javascript 原型和繼承(Prototypes and Inheritance)
前面我們看到了如何使用 constructor 來(lái)初始化對(duì)象。如果這樣做,那么每一個(gè)創(chuàng)建的新對(duì)象都會(huì)對(duì)那些相同的屬性,方法建立一個(gè)獨(dú)立的副本。而實(shí)際上有更加有效的方法來(lái)指定方法,常量,以及其他一些可被所有該類(lèi)的對(duì)象共享的屬性。2009-04-04
微信小程使用swiper組件實(shí)現(xiàn)圖片輪播切換顯示功能【附源碼下載】
這篇文章主要介紹了微信小程使用swiper組件實(shí)現(xiàn)圖片輪播切換顯示功能,涉及swiper組件相關(guān)屬性使用技巧,并附帶源碼供讀者下載參考,需要的朋友可以參考下2017-12-12

