Can someone help me to find out why animation on <h5>
element doesn't work?
#hero h5 {
animation: fadein 2s;
-moz-animation: fadein 2s; /* Firefox */
-webkit-animation: fadein 2s; /* Safari and Chrome */
-o-animation: fadein 2s; /* Opera */
font-weight: strong;
font-size: 28px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<section id="hero">
<div class="content">
<div class="container">
<div class="row">
<h5>Lorem Ipsum Demo Title</h5>
</div><!-- row -->
</div> <!-- container -->
</div> <!-- content -->
</section><!-- section -->
CSS allows animation of HTML elements without using JavaScript or Flash! In this chapter you will learn about the following properties: @keyframes. animation-name.
The @keyframes rule specifies the animation code. The animation is created by gradually changing from one set of CSS styles to another. During the animation, you can change the set of CSS styles many times.
CSS properties that define animation parameters such as animation-direction and animation-name are not animatable because animating them would create complex recursive behavior.
You are calling fadein
animation in your code but you haven't defined it anywhere.
CSS3 animations are defined with @keyframes
rule. More Information about CSS3 animations is Here.
Add following css:
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#hero h5 {
animation: fadein 2s;
-moz-animation: fadein 2s; /* Firefox */
-webkit-animation: fadein 2s; /* Safari and Chrome */
-o-animation: fadein 2s; /* Opera */
font-weight: strong;
font-size: 28px;
}
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section id="hero">
<div class="content">
<div class="container">
<div class="row">
<h5>Lorem Ipsum Demo Title</h5>
</div><!-- row -->
</div> <!-- container -->
</div> <!-- content -->
</section><!-- section -->
#hero h5 {
font-weight: strong;
font-size: 28px;
-webkit-animation-delay: 0.7s;
-moz-animation-delay: 0.7s;
animation-delay: 0.7s;
}
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.fade-in {
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:1s;
-moz-animation-duration:1s;
animation-duration:1s;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<section id="hero">
<div class="content">
<div class="container">
<div class="row">
<h5 class="fade-in">Lorem Ipsum Demo Title</h5>
</div><!-- row -->
</div> <!-- container -->
</div> <!-- content -->
</section><!-- section -->
You must define a animation named fadeIn
- as shown below.
Currently, you are using an animation but you have never created it.
@keyframes fadeIn {
0% {
transform: translate(0,0)
}
30% {
transform: translate(5px,0)
}
55% {
transform: translate(0,0)
}
80% {
transform: translate(5px,0)
}
100% {
transform: translate(0,0)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With