Mor*_*ari 4 html css css3 css-animations
有人可以帮我找出为什么<h5>
元素上的动画不起作用?
#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;
}
Run Code Online (Sandbox Code Playgroud)
<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 -->
Run Code Online (Sandbox Code Playgroud)
Moh*_*man 13
您fadein
在代码中调用动画,但您没有在任何地方定义它.
CSS3动画是用@keyframes
规则定义的.有关CSS3动画的更多信息,请点击此处.
添加以下css:
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
Run Code Online (Sandbox Code Playgroud)
#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;
}
}
Run Code Online (Sandbox Code Playgroud)
<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 -->
Run Code Online (Sandbox Code Playgroud)