html - 如何在我的滑块文本上添加过渡或淡入效果
问题描述
我希望当我向前点击时,必须有一个关于如何实现这一目标的过渡。请帮助解决这个问题。它只是引导程序的正常滑块。我已经看到了对图像的影响,但没有看到对文本的影响
.first1,.second,.first{
background-color: teal;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css">
<title>Slider</title>
</head>
<body>
<div class="container">
<div class="carousel slider" data-ride="carousel" id="carouselExampleControls" >
<div class="carousel-inner">
<div class="carousel-item active first1">
<div class="text-center">
<p>hello1</p>
</div>
</div>
<div class="carousel-item first">
<div class="text-center">
<p>hello2</p>
</div>
</div>
<div class="carousel-item second">
<div class="text-center">
<p>hello3</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</body>
</html>
解决方案
我刚刚向该类添加了一个简单的 css 动画,因此该类被添加到下一张幻灯片中,active
文本从opacity:0
opacity:1
.first1,.second,.first{
background-color: teal;
}
.active p {
opacity:0;
animation-name:opacity;
animation-duration:1s;
animation-fill-mode:forwards;
}
@keyframes opacity {
from {opacity:0;}
to {opacity:1;}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css">
<title>Slider</title>
</head>
<body>
<div class="container">
<div class="carousel slider" data-ride="carousel" id="carouselExampleControls" >
<div class="carousel-inner">
<div class="carousel-item active first1">
<div class="text-center">
<p>hello1</p>
</div>
</div>
<div class="carousel-item first">
<div class="text-center">
<p>hello2</p>
</div>
</div>
<div class="carousel-item second">
<div class="text-center">
<p>hello3</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</body>
</html>
推荐阅读
- sql - 删除重复的 XML 节点 SQL 查询
- javascript - 我曾尝试在 reactjs 类中调用 api,但是即使在 redux api 上调用了多次调用功能组件 api,api 也被调用了很多次
- sql - 当我在“WHERE”上使用 Datepicker 时,我无法查看所有数据
- python - 如何保存插入在 Python 中的类调用中的函数数量?
- java - 从附加代理或使用 com.sun.tools.attach.* 启动 JavaFlightRecorder;
- python-3.x - 如何在Django中将上传文件的名称显示为下载链接
- android - 来自 Google Fit 应用程序的连续心率监测
- grafana - 在 Grafana 中隐藏网格和 y 轴上的一些值
- php - Paytm All-in-one Sdk in laravel 系统错误
- mysql - 带有 mysql 的教义序数(错误:预期文字,得到'@')