html+css基礎彈窗(源代碼)


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="./css/login.css"/>
<style type="text/css">
/* *{
margin: 0px;
padding: 0px;
}
body, .box{
width: 100%;
height: 600px;

}
body{
position: relative;
}
.box{
position: absolute;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.333);
display: flex;
justify-content: space-around;
align-items: center;
display: none;
}
.box .content .close{
float: right;
width: 16px;
display: block;
}
.box .content{
width: 750px;
height: 300px;
background-color: white;
}
*/

body{
margin: 0;
}
.content{
background-color: rgba(0,0,0,0.333);
height: 600px;
display: flex;
justify-content: space-around;
align-items: center;
}
.content .box{
width: 750px;
height: 380px;
background: url(../img/pop-bg.jpg);
display: flex;
justify-content: flex-end;
}

.content .box .right{
height: 260px;
width: 260px;
/* background-color: #4449; */
margin-right: 60px;
margin-top: 40px;
padding: 20px;
}
.content .box .right .title{
font-size: 0;
}
.content .box .right .title a{
font-size: 20px;
color: #333333;
text-decoration: none;
display: inline-block;
width: 130px;
text-align: center;
border-bottom: 1px solid #CCCCCC ;
padding-bottom: 15px;
}
.content .box .right .title .active{
color: #27d5bf;
border-bottom: 3px solid #27d5bf ;
padding-bottom: 14px;
}
.content .box .right .text div{
margin: 20px 0;
}
.content .box .right .text div input[type=text],
.content .box .right .text div input[type=password]{
width: 252px;
height: 28px;
outline: 1px solid #CCCCCC;
border-radius: 4px;
border: none;
}
.content .box .right .text div input[type=text]:focus,
.content .box .right .text div input[type=password]:focus{
outline: 1px solid #27D5BF;
border-color: transparent;
}
.content .box .right .text div input[type=submit]{
width: 260px;
height: 32px;
color: white;
background-color: #27D5BF;
border: none;
font-size: 19px;
}
.content .box .right .text form{
display: none;
}
.content .box .right .text form:first-child{
display: block;
}

</style>
<!-- <script type="text/javascript">
window.onload=function(){
var btn=document.querySelector("button");
btn.onclick=function(){
var box=document.querySelector(".box");
box.style.display="flex";
}
var close=document.querySelector(".close");
close.onclick=function(){
var box =document.querySelector(".box");
box.style.display="none";
}
}
</script> -->
<script type="text/javascript">
window.onload=function(){
var forms=document.querySelectorAll(".box .text form");
// 尋找2個from表格
var btns=document.querySelectorAll(".box .title a");
// 尋找2個a標簽
for(var i=0;i<btns.length;i++){
// 循環找到2個a標簽,並給第一個a標簽添加點擊事件
btns[i].onclick=function(){
for (var j=0;j<btns.length;j++) {
// 把點擊后所有a標簽classname清空
btns[j].className= "";
//
}
this.className="active";
// 給點擊的這個a標簽添加classname
var idx=this.attributes["data-idx"].value;
console.log(idx);
// html代碼生明一個值,用來調用from
for(var j=0;j<forms.length;j++){
forms[j].style.display="none";
//點擊這個a標簽,然后所有form的樣式變成不顯示
}
forms[idx].style.display="block";
//點擊a標簽,然后點擊的那個form顯示
}
}
}
</script>
</head>
<body>
<!-- <button type="button">顯示登陸框</button>
<div class="box">
<div class="content">
<span class="close">&times;</span>
</div>
</div> -->


<div class="content">
<div class="box">
<div class="right">
<div class="title">
<a href="#" class="active" data-idx="0">登錄</a>
<a href="#" data-idx="1" >注冊</a>
</div>
<div class="text">
<form action="#" method="get">
<div>
<input type="text" name="name" id="name" value="" />
</div>
<div>
<input type="password" name="pwd" id="pwd" value="" />
</div>
<div>
<input type="checkbox" name="chk" id="chk" value="" />
<label for="chk">自動登錄</label>
</div>
<div><input type="submit" value="登錄"/></div>
</form>

<form action="" method="get">

<input type="submit" value=""/>

</form>
</div>
</div>
</div>
</div>
</body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM