我想在背景图片上显示带有文字动画的文字。当滑块更改时,新文本应显示新动画。我如何在bootstrap中实现这一目标?
答案 0 :(得分:0)
这是代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.m1{
color: red;
}
.m2{
color:blueviolet;
}
.m3{
color:chartreuse;
}
</style>
</head>
<body>
<div class="container">
<h2>Carousel Example</h2>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="1.jpg" alt="Los Angeles" style="width:100%;">
<div class="carousel-caption">
<h3 class="m1">Los Angeles</h3>
<p class="m1">LA is always so much fun!</p>
</div>
</div>
<div class="item">
<img src="2.jpg" alt="Chicago" style="width:100%;">
<div class="carousel-caption">
<h3 class="m2">Chicago</h3>
<p class="m2">Thank you, Chicago!</p>
</div>
</div>
<div class="item">
<img src="3.jpg" alt="New York" style="width:100%;">
<div class="carousel-caption">
<h3 class="m3">New York</h3>
<p class="m3">We love the Big Apple!</p>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</body>
</html>
你可以查看小提琴:https://jsfiddle.net/bfg2e0L3/