问题描述
大家下午好!我决定创建一个表单,其中我的叠加层将在不同的表单侧之间进行交换(取决于用户单击的内容),并遇到以下问题:看来我的叠加层的z-index值比容器的背景低(这是正确的侧面,左就可以了)
我阅读了很多文章,但找不到解决方案。随附有错误的屏幕截图,请帮助我Here is a mistake找到解决方法。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<script src="script.js" defer></script>
<title>Document</title>
<style>
*{
box-sizing: border-box;
padding: 0;
margin: 0;
}
body{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
.container{
background : grey;
width: 700px;
min-height: 600px;
position: relative;
overflow: hidden;
}
/* All for forms */
.forms{
position: absolute;
top: 0;
height: 100%;
width: 50%;
background: #333;
}
.formsSignin{
position: absolute;
z-index: 3;
background: #f4f4f4;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
transform: translateX(0);
transition: all 0.9s ease-in-out;
}
.formsSignin h1{
color: blue;
font-weight: bold;
}
.formsSignin input{
width: 80%;
padding: 10px 20px;
margin: 10px 0;
border-radius: 5px;
outline: none;
border: 3px solid green;
}
.formsSignup{
position: absolute;
z-index: -1;
transition: all 0.9s ease-in-out;
}
/* Overlays */
.overlay{
position: absolute;
color: green;
height: 100%;
width: 50%;
top: 0;
overflow: hidden;
}
.overStyle{
position: absolute;
z-index: 10;
background: pink;
left: -100%;
width: 100%;
height: 100%;
transform: translateX(140%);
}
.right-overlay{
position: absolute;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
transform: translateX(100%);
right: 0;
transition: all 0.9s ease-in-out;
}
.left-overlay{
position: absolute;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
left: 0;
transform: translateX(-20%);
transition: all 0.9s ease-in-out;
}
/* Utilities */
button{
display: inline-block;
padding: 10px 40px;
margin-top: 10px;
color: #fff;
border-radius: 10px;
border: none;
cursor: pointer;
outline: none;
transition: transform 0.9s ease-in-out;
}
button::active{
transform: scale(0.90);
}
button.primary{
background: red;
}
button.secondary{
background: blue;
}
/* Animation */
.container.right-button-clicked .formsSignin{
transform: translateX(100%);
}
.container.right-button-clicked .right-overlay{
transform: translateX(0);
}
.container.right-button-clicked .left-overlay{
transform: translateX(0);
z-index: 5;
}
</style>
</head>
<body>
<div class="container" id="container">
<div class="forms">
<div class="formsSignin">
<h1>Log into account</h1>
<input type="text" placeholder="nickname">
<input type="password" placeholder="password">
<button class="primary">
Sign in
</button>
</div>
<div class="formsSignup">
<h1>Create account</h1>
<input type="text" placeholder="email">
<input type="password" placeholder='password'>
</div>
</div>
<div class="overlay">
<div class="overStyle">
<div class="right-overlay">
<p>Don't have account? Create here</p>
<button class="secondary" id='signin'>Sign Up</button>
</div>
<div class="left-overlay">
<p>Already a user?</p>
<button class="secondary">Sign In</button>
</div>
</div>
</div>
</div>
</body>
</html>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)