【发布时间】:2016-12-18 05:09:42
【问题描述】:
在隐藏类.button 之后,如何使隐藏的form 从右到左动画。我可以制作类似的东西,但我无法同步它们的动画。
当button被点击时,它会向右移动一些像素然后被隐藏,在它被隐藏之前,我想让form动画。
如何创建与.button 类中的表单相同的效果,并从那里出现?
非常感谢任何帮助!
这里是小提琴:fiddle link
【问题讨论】:
在隐藏类.button 之后,如何使隐藏的form 从右到左动画。我可以制作类似的东西,但我无法同步它们的动画。
当button被点击时,它会向右移动一些像素然后被隐藏,在它被隐藏之前,我想让form动画。
如何创建与.button 类中的表单相同的效果,并从那里出现?
非常感谢任何帮助!
这里是小提琴:fiddle link
【问题讨论】:
试试这个fiddle更新
在本例中,我们使用CSS3 动画。
【讨论】:
$('a.button').click(function() {
$(this).addClass('hidden-btn');
$('.myform').fadeIn('slow');
$('.myform input').focus();
});
.wrapper {
overflow: hidden;
height: 200px;
}
.button {
font-size: 18px;
background-color: lightblue;
width: 222px;
text-align: center;
height: 44px;
line-height: 40px;
text-transform: uppercase;
display: inline-block;
font-weight: 700;
margin-top: 100px;
left: 50%;
transform: translateX(-50%);
position: relative;
transition: all 0.4s
}
.hidden-btn {
left: 200%;
}
.myform {
float: left;
position: relative;
margin-top: 100px;
display: none;
left: 50%;
top: -145px;
transform: translateX(-50%);
}
.myform input {
float: left;
width: 284px;
height: 40px;
padding-left: 63px;
padding-right: 5px;
margin-top: 1px;
border: none;
color: #767676;
font-size: 13px;
background-color: lighgrey;
}
.myform button {
width: 170px;
height: 44px;
border: 0;
text-transform: uppercase;
color: #fff;
font-size: 16px;
background-color: lighblue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<a href="#" class="button">Test</a>
<form class="myform" action="">
<input type="text" placeholder="Email">
<button type="submit">try</button>
</form>
</div>
【讨论】:
.myform { top: -145px;}属性