【发布时间】:2017-12-19 07:11:57
【问题描述】:
一段时间以来,我一直在浏览版块和论坛,试图弄清楚为什么我的轮播无法加载/滚动。我读到必须链接到 popper.js 文件,读到关于在引导之前加载 jquery 和 popper,以及很多其他问题。一旦我开始加载 popper.js,我的控制台就不会出现任何错误。谁能在我的 HTML 中看到问题并告诉我为什么轮播不会自动滚动或使用字形图标滚动?当我单击轮播时,它什么也不做,给我任何错误或转到#theCarousel,就像在我加载 popper js 文件之前所做的那样。感谢任何人提供的任何帮助。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- If IE use the latest rendering engine -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Set the page to the width of the device and set the zoon level -->
<meta name="viewport" content="width = device-width, initial-scale = 1">
<title>Bootstrap Tutorial</title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Pacifico" rel='stylesheet' type='text/css'>
<style type="text/css">
/* Carousel Styling */
.slide1{
background-image: url('./img/bkgrnd1.jpeg');
height: 500px;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.slide2{
background-image: url('./img/bkgrnd2.jpg');
height: 500px;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.slide3{
background-image: url('./img/bkgrnd3.jpg');
height: 500px;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.slide1{
background-image: url('./img/bkgrnd4.jpeg');
height: 500px;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.carousel-caption h1{
font-size: 5.4em;
font-family: 'Pacifico', cursive;
padding-bottom: .4em;
}
.carousel-caption p{
font-size: 2em;
}
</style>
<body>
<div id="theCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#theCarousel" data-slide-to="0" class="active"></li>
<li data-target="#theCarousel" data-slide-to="1"></li>
<li data-target="#theCarousel" data-slide-to="2"></li>
<li data-target="#theCarousel" data-slide-to="3"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<div class="slide1"></div>
<div class="carousel-caption">
<h1>Amazing Backgrounds</h1>
<p>Thousands of Backgrounds for Free</p>
<p><a href="#" class="btn btn-primary btn-sm">Get them now!</a></p>
</div>
</div>
<div class="item">
<div class="slide2"></div>
<div class="carousel-caption">
<h1>This is SLIDE TWOO</h1>
<p>Thousands of SLIDE TWOS for Free</p>
</div>
</div>
<div class="item">
<div class="slide3"></div>
<div class="carousel-caption">
<h1>Amazing ILLUSIONS</h1>
<p>Thousands of SLIDE THREES for Free</p>
</div>
</div>
<div class="item">
<div class="slide4"></div>
<div class="carousel-caption">
<h1>Amazing COLORS</h1>
<p>Thousands of SLIDE FOURS for Free</p>
<p><a href="#" class="btn btn-primary btn-sm">BUTTON 4!</a></p>
</div>
</div>
</div>
<a class="left carousel-control" href="#theCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<a class="right carousel-control" href="#theCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</body>
</html>
【问题讨论】:
-
afaik,popper 适用于 bootstrap 4。你使用的是正确的 bootstrap js 版本吗?你的 CSS 是第 3 版
-
你是对的。我在使用今晚下载的自己的引导 css 文件时遇到问题,不确定它是什么版本。所以我链接到它并修复它。但我只是尝试使用没有 popper 的 v3,你是对的,它不需要它。
标签: javascript jquery html twitter-bootstrap-3 carousel