Can I make a similar animation only with CSS3

I am working on a website and now I need to do the intro animation just like this http://www.elitemodel.fr/

On this website, when I load the page, the logo and backgroung are shifted to the left. My client wants this effect on his website.

I am currently creating an intro.php page with this html code:

<div class="intro">
    <div class="logo-intro"></div><!-- /.logo logo-intro -->
</div><!-- /.intro -->
<div class="black_overlay"></div><!-- /.logo logo-intro -->

I am trying to do this with css3 and a little javascript.

After html, this is my CSS code for the animation:

.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;}
}

After the animation finishes, I redirect intro.php to the home page using javascript

// Your application has indicated there 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);

This works, but how can I make this animation without redirecting?

Hello,

+4
source share
2

-

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>
+1

, . .

0

Source: https://habr.com/ru/post/1620433/


All Articles