一切都可以在我的自举轮播中使用,但即使我添加了“ slide” CSS标签也不会产生滑动效果。图像快速变化;他们没有 幻灯片 。
夫妇笔记:
有什么想法吗?
这是我的HTML。
<!DOCTYPE html>
<html lang="en-us">
<head>
<link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css" />
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="row">
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="4000">
<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>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="images/slider-1.png" class="d-block w-100" />
</div>
<div class="carousel-item">
<img src="images/slider-2.png" class="d-block w-100" />
</div>
<div class="carousel-item">
<img src="images/slider-3.png" class="d-block w-100" />
</div>
</div>
<div class="carousel-controls">
<a class="carousel-control-prev" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="/shared/js/jquery-3.4.1.min.js"></script>
<script src="/plugins/bootstrap/js/bootstrap.min.js"></script>
</html>
答案 0 :(得分:0)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="row">
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="4000">
<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>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://cdn.pixabay.com/photo/2013/07/12/17/47/test-pattern-152459__340.png" class="d-block w-100" />
</div>
<div class="carousel-item">
<img src="https://cdn.pixabay.com/photo/2013/07/12/17/47/test-pattern-152459__340.png" class="d-block w-100" />
</div>
<div class="carousel-item">
<img src="https://cdn.pixabay.com/photo/2013/07/12/17/47/test-pattern-152459__340.png" class="d-block w-100" />
</div>
</div>
<div class="carousel-controls">
<a class="carousel-control-prev" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<footer>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="script.js"></script>
</footer>
</html>
我在repl.it的<body> </body>
部分中使用了您的代码,它可以正常工作,但是存在一些尺寸问题。将代码复制到此处,您可以运行它并亲自查看:)它也会滑动
编辑*
我看到您要将轮播插入行和列中,不要以为应该这样做,但是如果您要进行正确的尺寸调整,则轮播会在每次滑动时断开行和列
删除代码中的此部分,以使轮播正常工作
<div class="row">
<div class="col">
<div class="row">
此外,我认为您的网站不起作用的原因是由于您的HTML结构,并且引导js和CSS CDNS没有正确导入。
getbootstrap.com有一个启动程序/锅炉模板,您可以始终将其与正确的导入,布局等一起使用。
在这里看到 https://getbootstrap.com/docs/4.3/getting-started/introduction/#starter-template