我正在使用此网站上的模板创建主页:https://startbootstrap.com/template-overviews/full-slider/但我无法让它正常工作。我可以加载我的所有图像,但是当我预览页面时,每个图像的标题重叠,按钮不起作用,图片显示不正确(我看到我的第一张图片,然后是页脚,然后是我的另外两张图片在页脚之后。)
这是我的索引:
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="risorse/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link href="risorse/stili/starter-template.css" rel="stylesheet">
<link href="risorse/stili/full-slider.css" rel="stylesheet">
</head>
这里是我的滑块:
<!-- Full Page Image Background Carousel Header -->
<header id="myCarousel" class="carousel slide">
<!-- Indicators -->
<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>
<!-- Wrapper for Slides -->
<div class="carousel-inner">
<div class="item active">
<!-- Set the first background image using inline CSS below. -->
<div class="fill" style="background-image:url('risorse/immagini/slider_1.jpg');"></div>
<h2>Chiesa San Marco - Baucina</h2>
</div>
</div>
<div class="item">
<!-- Set the second background image using inline CSS below. -->
<div class="fill" style="background-image:url('risorse/immagini/slider_2.jpg');"></div>
<div class="carousel-caption">
<h2>Mostra Expo Canina 2016 - Baucina</h2>
</div>
</div>
<div class="item">
<!-- Set the third background image using inline CSS below. -->
<div class="fill" style="background-image:url('risorse/immagini/slider_3.jpg');"></div>
<div class="carousel-caption">
<h2>Paesaggio Siciliano</h2>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="icon-next"></span>
</a>
</header>
在页脚之后我有以下滑块的jquery函数:
<script src="risorse/js/jquery.js"></script>
<script src="risorse/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="risorse/jquery/jquery-3.1.1.min.js"><\/script>')</script>
<script>
$('.carousel').carousel({
interval: 5000 //changes the speed
})
</script>
这是我的初学者模板CSS:
html {
position: relative;
height: 100%;
}
body {
padding-top: 50px;
/* Margin bottom by footer height */
margin-bottom: 60px;
height: 100%;
}
.starter-template {
padding: 40px 15px;
text-align: center;
}
.footer {
position: relative;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
background-color: black;
}
.footer p {
margin: 10px 0;
}
这是完整的滑块CSS:
.carousel,
.item,
.active {
height: 100%;
}
.carousel-inner {
height: 100%;
}
/* Background images are set within the HTML using inline CSS, not here */
.fill {
width: 100%;
height: 100%;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
我检查了控制台,我收到此错误:未捕获TypeError:$(...)。carousel不是函数。我正在尝试解决方案,但似乎没有任何工作,但是。
答案 0 :(得分:1)
尝试仅加载一次jquery库。 在bootstrap之前只加载一个版本的jquery,对于Bootstrap 3,jQuery的依赖关系设置为版本1.9.0或高我认为