我在div上设置绝对位置,以便我可以在网页中心,一切都很顺利,直到我想为div加载一个轻微的fadeInDown。每当我在Y中翻译div时,它会在页面上对角线移动吗?
我有一种感觉,我将不得不重新制作整个东西,但使用display:table或display:flex?但在我改写页面之前,我只想要确认。
HTML:
<body>
<div class="section">
<div class="wrapper">
<div class="content">
<h2>Contact Me</h2>
<form action="contactme.php" method="post" class="contact-form">
<div class="input-field">
<input type="text" name="name" required="">
<label for="">Full Name</label>
</div>
<div class="input-field">
<input type="text" name="cname" required="">
<label for="">Company Name</label>
</div>
<div class="input-field">
<input type="text" name="website" required="">
<label for="">Current Website (N/A if None)</label>
</div>
<div class="input-field">
<input type="email" name="mail" required="">
<label for="">E-Mail</label>
</div>
<div class="input-field">
<textarea name="message" rows="5" required=""></textarea>
<label for="">Message</label>
</div>
<input type="submit" name="submit" value="Submit Message" class="btn">
</form>
</div>
</div>
</div>
<script src=""></script>
</body>
CSS:
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed');
body {
margin: 0;
padding: 0;
font-family: 'Roboto Condensed', sans-serif;
width: 100%;
height: 100vh;
background: linear-gradient(to bottom, rgba(0, 142, 204, 5) 50%, rgba(253, 165, 15, 5) 50%);
}
.wrapper {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 600px;
padding: 40px;
box-sizing: border-box;
background: #FFF;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
animation: fadeInDown 2s 0s linear;
}
.wrapper h2 {
color: #666;
margin: 0;
padding: 0;
text-align: center;
font-size: 30px;
text-transform: uppercase;
}
.input-field {
position: relative;
width: 100%;
margin-top: 50px;
}
.input-field input,
.input-field textarea {
font-family: 'Roboto Condensed', sans-serif;
width: 100%;
padding: 5px 0;
box-sizing: border-box;
background: transparent;
border: none;
outline: none;
border-bottom: 2px solid #666;
font-size: 16px;
color: #666;
font-weight: 700;
text-transform: uppercase;
resize: none;
}
.input-field label {
position: absolute;
top: 0;
left: 0;
padding: 5px 0;
pointer-events: none;
font-size: 16px;
color: #666;
font-weight: 700;
transition: .5s;
}
.input-field input:focus + label,
.input-field textarea:focus + label,
.input-field input:valid + label,
.input-field textarea:valid + label {
top: -25px;
font-size: 14px;
padding: 2px 5px;
background: #FF006A;
color: #FFF;
border-radius: 4px;
}
.btn {
font-family: 'Roboto Condensed', sans-serif;
margin-top: 20px;
background: linear-gradient(to right, #ff9966, #ff5e62);
color: #FFF;
padding: 15px 30px;
border: none;
outline: none;
border-radius: 30px;
font-size: 16px;
float: right;
transition: all .5s;
}
.btn:hover {
cursor: pointer;
}
@media(max-width: 580px) {
.wrapper {
width: 250px;
padding: 20px;
}
.wrapper h2 {
font-size: 15px;
}
.input-field input,
.input-field textarea {
font-size: 12px;
}
.input-field label {
font-size: 12px;
}
.btn {
font-size: 12px;
}
}
@keyframes fadeInDown {
0% {
transform: translateY(-20%);
opacity: 0;
}
50% {
transform: translateY(0%);
opacity: 1;
}
}
图片:
https://i.gyazo.com/de7c60b9f6456e2e51b89a86f9df1fc7.mp4 https://gyazo.com/2598e76252520340714b12d3976a4ce5
提前谢谢。