【发布时间】:2013-09-07 15:58:15
【问题描述】:
我制作了这个脚本来为面板设置动画(打开-关闭):
$(window).load(function () {
var z = '';
$("#painel").hide()
$(".btvagas").click(function () {
z++;
$("#painel").animate({
width: 'toggle'
});
if (z === 1) {
$("#painel").animate({
width: '400px'
});
$(".btvagas").animate({
left: '336px'
});
} else {
$(".btvagas").animate({
left: '-65px'
});
z = 0;
}
})
});
您可以在此处查看所有带有 html 和 css 的代码: http://codepen.io/LuanPiegas/pen/wFyjG
但是,我是 jQuery 和 JavaScript 的新手,所以...有更好的方法来做到这一点,结果相同?
【问题讨论】:
-
实际上,为您想要做的动画制作“最佳”方式是使用 CSS3 变换。并非所有浏览器都支持它,因此您还需要回退到 jquery。看看这篇文章:html5rocks.com/en/tutorials/speed/html5 和这篇文章:paulirish.com/2012/…
标签: javascript jquery css jquery-animate