我在当前正在构建的网站上有一个登录表单,我也有一个注册表单.当单击注册"链接时,我想通过将 div 旋转到另一侧来添加一些精美的动画.我希望登录表单位于正面,而注册表单位于背面.我宁愿不使用 javascript,但如果有必要,我会.
I have a login form on a site I am currently building, and I also have a signup form. I would like to add some fancy animation to it by rotating the div to the other side when the "Sign up" link is clicked. I want the login form to be on the front side, and the signup form on the back. I would rather not use javascript, but if necessary, I will.
感谢您提供任何可能的答案!
Thanks for any possible answers!
您可以使用 CSS transition 和 transform: rotateY() 来制作动画,无需 Javascript,其他而不是通过添加一个类来触发动画.
You can do the animation using CSS transition and transform: rotateY() with no Javascript, other than triggering the animation by adding a class.
演示:http://jsfiddle.net/ThinkingStiff/9UMFg/
CSS:
.flip {
backface-visibility: hidden;
border: 1px solid black;
height: 150px;
position: absolute;
transform-origin: 50% 50% 0px;
transition: all 3s;
width: 300px;
}
#side-1 {
transform: rotateY( 0deg );
}
#side-2 {
transform: rotateY( 180deg );
}
.flip-side-1 {
transform: rotateY( 0deg ) !important;
}
.flip-side-2 {
transform: rotateY( 180deg ) !important;
}
HTML:
<form id="side-1" class="flip">
<div>login</div>
<input id="username" placeholder="enter username" />
<input id="password" placeholder="enter password" />
<a id="login" href="#">login</a>
<a id="signup" href="#">sign up</a>
</form>
<form id="side-2" class="flip">
<div>signup</div>
<input id="new-username" placeholder="enter username" />
<input id="new-password" placeholder="enter password" />
<input id="new-re-password" placeholder="re-enter password" />
<a id="create" href="#">create</a>
</form>
脚本:
document.getElementById( 'signup' ).addEventListener( 'click', function( event ) {
event.preventDefault();
document.getElementById( 'side-2' ).className = 'flip flip-side-1';
document.getElementById( 'side-1' ).className = 'flip flip-side-2';
}, false );
这篇关于用html的两侧翻转div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
即使在调用 abort (jQuery) 之后,浏览器也会等待Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在调用 abort (jQuery) 之后,浏览器也会等待 ajax 调用
XMLHttpRequest 无法加载,请求的资源上不存在“AXMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 无法加载,请求的资
XMLHttpRequest、jQuery.ajax、jQuery.post、jQuery.get 有什么What is the difference between XMLHttpRequest, jQuery.ajax, jQuery.post, jQuery.get(XMLHttpRequest、jQuery.ajax、jQuery.post、jQuery.get 有什么区别
可以使用 xhrFields 将 onprogress 功能添加到 jQuery.Can onprogress functionality be added to jQuery.ajax() by using xhrFields?(可以使用 xhrFields 将 onprogress 功能添加到 jQuery.ajax() 吗?)
显示使用 XHR2/AJAX 下载文件的进度条Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)
如何在没有 jQuery 的情况下在 JavaScript 中打开 JHow can I open a JSON file in JavaScript without jQuery?(如何在没有 jQuery 的情况下在 JavaScript 中打开 JSON 文件?)