以下是使用中的简单轮播,即使它在编码中看起来不错,但是在浏览器上每当尝试单击next
或prev
按钮时,页面都 scrolled
在 HTML 的顶部。
<!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/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 70%;
margin: auto;
}
</style>
</head>
<body>
<h1>SAMPLE CONTENT HERE</h1>
<h1>SAMPLE CONTENT HERE</h1>
<h1>SAMPLE CONTENT HERE</h1>
<h1>SAMPLE CONTENT HERE</h1>
<div class="container">
<br>
<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> …
Run Code Online (Sandbox Code Playgroud)