Dynamic Page transitions

青春壹個敷衍的年華 提交于 2019-12-11 17:47:10

问题


I am trying to transition content with a @keyframes animation when loading and unloading content with Ajax. A active demo is currently here: Test Page

I thought maybe I could use no JavaScript but I am not sure if this will work? Could I be wrong in my CSS attempt below instead?

/* Animation Settings */
.aniDown {
z-index:0;
-webkit-animation-name: slideDown;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease;
-webkit-animation-direction:normal;
}

@-webkit-keyframes slideDown {
0%   { margin-top:-3000px; }
40%  { margin-top:-100px;  }
100% { margin-top:0px;     }
}

header a:active .aniDown, 
header a:focus .aniDown {
-webkit-animation-name: slideUp;
}

@-webkit-keyframes slideUp {
0%   {margin-top:0px;}
20%  {margin-top:-1000px;}
100% {margin-top:-3000px;}
}

回答1:


Use translate3d(x,y,z) instead of margin-top. That speeds up the animation.

Otherwise, I have no straight answer since your code looks valid at first glance. But I've written an article about CSS Animations: http://samuli.hakoniemi.net/having-fun-with-css-keyframes/ . Maybe you should read it and compare whether you're doing something wrong.



来源:https://stackoverflow.com/questions/9899641/dynamic-page-transitions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!