我正在一个网站上工作,现在我必须制作一个与此 http://www.elitemodel.fr/完全相同的简介动画
在我加载页面时,在这个网站上,徽标和背景幕向左滑动.
我的客户在他的网站上想要这个效果.
现在,我用这个HTML代码创建一个页面intro.php:
<div class="intro">
<div class="logo-intro"></div><!-- /.logo logo-intro -->
</div><!-- /.intro -->
<div class="black_overlay"></div><!-- /.logo logo-intro -->
我试图用css3和小javascript来做这个.
在html之后,这是我的动画CSS代码:
.intro,
.intro .logo-intro {
overflow: hidden;
-moz-animation: slide 2s ease 1.5s forwards;
-webkit-animation: slide 2s ease 1.5s forwards;
-o-animation: slide 2s ease 1.5s forwards;
-ms-animation: slide 2s ease 1.5s forwards;
animation: slide 2s ease 1.5s forwards;
}
@-moz-keyframes slide /* Firefox */
{
from {width: 100%; }
to {width: 0;}
}
@-webkit-keyframes slide /* Safari and Chrome */
{
from {width: 100%;}
to {width: 0;}
}
@-o-keyframes slide /* Opera */
{
from {background: white;}
to {background: black;}
}
@-ms-keyframes slide /* IE10 */
{
from {width: 100%;}
to {width: 0;}
}
@keyframes slide
{
from {width: 100%;}
to {width: 0;}
}
}
.logo-intro {
-webkit-animation: logo 1s; /* Chrome, Safari, Opera */
-webkit-animation-iteration-count: 2; /* Chrome, Safari, Opera */
-webkit-animation-fill-mode: forwards; /* Chrome, Safari, Opera */
animation: logo 1s;
animation-iteration-count: 2;
animation-fill-mode: forwards;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes logo {
from {top: 50%;}
to {left: -99999px;}
}
@keyframes logo {
from {top: 50%;}
to {left: -99999px;}
}
动画结束后,我使用javascript将intro.php重定向到主页
// Your application has indicated there's an error
window.setTimeout(function(){
// Move to a new location or you can do something else
var url = "http://www.gaelscalpaesthetics.com/accueil";
$(location).attr('href',url);
}, 4000);
这是有效的,但如何在不重定向的情况下制作此动画?
问候,
最佳答案 尝试这样的事情
DEMO
body, html {
max-width: 100%;
overflow-x: hidden;
}
.logo,
.black-bg {
display: flex;
min-height: 100vh;
min-width: 100vw;
position: fixed;
justify-content: center;
align-items: center;
font-size: 50px;
}
.logo {
z-index: 1;
background: white;
animation: animateLogo 2s ease-in-out 1.3s forwards;
}
.black-bg {
background: black;
z-index: 2;
transform: translateX(100vw);
animation: animateBlackBg 1.5s ease-in-out 1.5s forwards;
}
.content {
display: flex;
flex-direction: row;
height: 100vh;
width: 100%;
}
.content img {
flex: 1;
padding: 20px;
}
@keyframes animateLogo {
80% {
transform: translateX(-100vw);
opacity: 1;
}
100% {
transform: translateX(-100vw);
opacity: 0;
}
}
@keyframes animateBlackBg {
40% {
transform: translateX(0);
opacity: 1;
}
80% {
transform: translateX(0);
opacity: 1;
}
100% {
transform: translateX(0);
opacity: 0;
}
}
<div class="logo">LOGO</div>
<div class="black-bg"></div>
<div class="content">
<img src="http://placehold.it/500x900">
<img src="http://placehold.it/500x900">
</div>