CSS 3 Animation works weird and doesn't work for Chrome

I'm trying to create an animation with CSS3 animations. Basically when I load page, I would like the h1 gone from down to up and intro paragraph slides from right to left

Order:

1) Paragraph slides from right to left-center page;

2) Then the title (hello) slide from up to down.

p.intro {
  -webkit-animation: dadestra 4s;
  -moz-animation: dadestra 4s;
  -ms-animation: dadestra 4s;
  -o-animation: dadestra 4s;
  animation: dadestra 4s;
  animation-name: dadestra;
  animation-duration: 3s;
  position:relative;
  animation-delay:-1s;
}

@keyframes dadestra {
    0% { left: 100%;}
    100%{ left: 0%;}
}

@-moz-keyframes dadestra {
    0% { left: 100%;}
    100%{ left: 0%;}
}

@-webkit-keyframes dadestra {
    0% { left: 100%;}
    100%{ left: 0%;}
}

@-o-keyframes dadestra {
  0% { left: 100%;}
  100%{ left: 0%;}
}

@-ms-keyframes dadestra {
  0% { left: 100%;}
  100%{ left: 0%;}
}



/* Welcome */

h1 {
  color:#fff;
  text-align: center;
  background:#111112;
  text-shadow: 1px 1px 1px red;
  border-radius: 10px 10px 10px;
  box-shadow: 0px 1px 7px 1px red;
  position:relative;
  -webkit-animation: hello;
  animation-name: hello;
  animation-duration: 4s;
  -webkit-animation-duration: 4s;
  -moz-animation-duration: 4s;
  -ms-animation-duration: 4s;
  -o-animation-duration: 4s;
  z-index:1;
  
}

@keyframes hello {
   0%  { top:60%; left: 0%; }
  75% {top: 30%; left: 0%; }
  100% { top:0%; left: 0%; }
}

@-moz-keyframes hello {
   0%  { top:60%; left: 0%; }
  75% {top: 30%; left: 0%; }
  100% { top:0%; left: 0%; }
}

@-webkit-keyframes hello {
   0%  { top:60%; left: 0%; }
  75% {top: 30%; left: 0%; }
  100% { top:0%; left: 0%; }
}

@-ms-keyframes hello {
   0%  { top:60%; left: 0%; }
  75% {top: 30%; left: 0%; }
  100% { top:0%; left: 0%; }
}

@-o-keyframes hello {
   0%  { top:60%; left: 0%; }
  75% {top: 30%; left: 0%; }
  100% { top:0%; left: 0%; }
}
<html>
<body>
<h1>Welcome guest!</h1>
        <p class="intro">bla bla bla bla</p>
        <p class="intro">bla bla bla</p>
</body>
</html>

I tried this code, dadestra it's the animation for the paragraph from right to left-center page. Paragraph it's ok, it works properly.

Issue with h1 animation: 2 problems:

it blinks in Firefox, looks that it works very weird;

In Chrome it doesn't appear, doesn't run.

I'm new to animations, I always avoid from flash ecc, but I have to do for university project, so be careful and if you know what's problem, tell me, Thanks advance!

Upvotes: 0

Views: 36

Answers (1)

Jack
Jack

Reputation: 1999

You should use transform: translate(). It will work better in this situation

body {
  overflow: hidden;
}

h2 {
  color:#fff;
  text-align: center;
  background:#111112;
  text-shadow: 1px 1px 1px red;
  border-radius: 10px 10px 10px;
  box-shadow: 0px 1px 7px 1px red;
  position:relative;
  
  
  animation: top 1s 1s;
  animation-fill-mode: forwards;
  
  transform: translateY(-100px);
}

@keyframes top {
  0% {
    transform: translateY(-100px);
  }
  
  100% {
    transform: translateY(0px);
  }
}

p {
  animation: left 1s;
}

@keyframes left {
  0% {
    transform: translateX(100vw);
  }
  
  100% {
    transform: translateX(0vw);
  }
}
<h2>Hello</h2>

<p>Paragraph is here</p>

Upvotes: 1

Related Questions