<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<title>Bootstrap 4 轮播</title>
</head>
<body>
<div class="container mt-4">
<h2>轮播示例</h2>
<div id="carouselExample" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://via.placeholder.com/1200x400" class="d-block w-100" alt="轮播图片1">
</div>
<div class="carousel-item">
<img src="https://via.placeholder.com/1200x400" class="d-block w-100" alt="轮播图片2">
</div>
<div class="carousel-item">
<img src="https://via.placeholder.com/1200x400" class="d-block w-100" alt="轮播图片3">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExample" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">上一个</span>
</a>
<a class="carousel-control-next" href="#carouselExample" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">下一个</span>
</a>
</div>
</div>
<!-- Bootstrap JavaScript 和 jQuery(可选)-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</body>
</html>
在这个例子中,我们使用了 carousel、carousel-inner、carousel-item、carousel-control-prev 和 carousel-control-next 等 Bootstrap 类来创建轮播组件。轮播内部使用了多个 carousel-item 来包裹轮播的每一项。
你可以根据需要添加更多的轮播项,调整图片和样式。这只是一个简单的示例,你可以根据实际需求进行更多的定制。
转载请注明出处:http://www.zyzy.cn/article/detail/5502/Bootstrap