我试图从一种表单字段类型转换为另一种。如果我插入另一个<input>
元素,则下一个元素的静态位置不会生成动画。JQuery/CSS:动画静态位置
$("#switchlogin").click(function() {
//Create the label element
var emaillabel = $("<label>").text("Email").attr("for", "email");
//Create the input element
var emailinput = $('<input type="text">').attr({
id: "email",
name: "email"
});
//Create the label element
var pwdlabel = $("<label>").text("Repeat Password").attr("for", "password-wh");
//Create the input element
var pwdinput = $('<input type="password">').attr({
id: "password-wh",
name: "password-wh"
});
$("#username-field").after(emaillabel);
emaillabel.after(emailinput);
$("#password-field").after(pwdlabel);
pwdlabel.after(pwdinput);
});
input {
border: solid #e3e3e3 1pt;
display: block;
margin-bottom: 1em;
font-size: 14pt;
opacity: 0;
animation: fadeIn .3s forwards;
}
label {
opacity: 0;
animation: fadeIn .3s forwards;
}
@keyframes fadeIn {
to {
opacity: 1;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="<?php the_permalink(); ?>" id="login" method="post">
<div id="username-field">
<label for="username">Username</label>
<input type="text" id="username" name="username">
</div>
<div id="password-field">
<label for="password">Password</label>
<input type="password" id="password" name="password">
</div>
<div id="buttons-field">
<button type="submit">Login</button>
<a href="#" id="switchlogin">Register</a>
</div>
</form>
https://jsfiddle.net/fpvctpjs/2/
所以,我想那是什么,按注册链接时,该password-field
向下移动顺畅,使地方的新元素。
我尝试了几件事情,如加入margin-top
,position:absolute
或position:relative
,但不知何故我不能得到它的工作。
感谢你的帮助,
marsman
我个人认为它不是一个好主意,添加输入登录形式成为登记表格..对我来说,我将创建2种独立的形式一个用于登录,一个用于寄存器和效果基本show之一,另一了slideDown ..再(为我)它是一种更好的方式来做到这一点.. –
无关你的问题,但值得一提:点击** **注册按钮将输入域_each time_ –