gpt4 book ai didi

javascript - 从 CDN 加载的 Bootstrap Carousel 无法正常工作

转载 作者:行者123 更新时间:2023-11-28 03:46:47 27 4
gpt4 key购买 nike

我过去是一名网页设计师,但我已经好几年没有接触过任何代码了。我想我犯了一个简单的错误,但我无法弄清楚。我正在尝试包含 Bootstrap 推荐文本轮播,但它不起作用。看起来 jQuery 和 bootstrap.js 确实可以工作,但 carousel 却不能。

我试图通过使用 CDN 使其变得 super 简单,因为这只是一个短期页面。我还把它全部削减到页面中不起作用的相关部分。我经常开始删除碎片,直到有办法解决问题,但这次我找不到它。非常感谢任何帮助!

<!DOCTYPE html>

见证测试 /* 轮播 */

    #quote-carousel {
padding: 0 10px 30px 10px;
margin-top: 30px;
}
/* indicator position */

#quote-carousel .carousel-indicators {
right: 50%;
top: auto;
bottom: -10px;
margin-right: -19px;
}
/* indicator color */

#quote-carousel .carousel-indicators li {
background: #c0c0c0;
}
/* active indicator */

#quote-carousel .carousel-indicators .active {
background: #333333;
height: 10px;
width: 10px;
margin-bottom: 1px;
}
</style>

<!-- FANS-->
<section id="fans">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6">
<div class="p-5">
<img class="img-fluid rounded-circle" src="img/fans.png" alt="">
</div>
</div>
<div class="col-lg-6 order-lg-1">
<div class="p-5">
<h2 class="display-4">Fans</h2>

<div class="container">
<div class="row">
<div class="col-md-12">
<div class="carousel slide" data-ride="carousel" id="quote-carousel">

<!-- Bottom Carousel Indicators -->
<ol class="carousel-indicators">
<li data-target="#quote-carousel" data-slide-to="0" class="active"></li>
<li data-target="#quote-carousel" data-slide-to="1"></li>
<li data-target="#quote-carousel" data-slide-to="2"></li>
</ol>

<!-- Carousel Slides / Quotes -->
<div class="carousel-inner">

<!-- Quote 1 -->
<div class="item active">
<div class="row">
<div class="col-sm-12">
<p>&ldquo;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Etiam porta sem malesuada magna mollis euismod. Nulla vitae elit libero, a pharetra augue. Donec id elit non mi porta gravida at eget metus.&rdquo;</p>
<small><strong>Vulputate M., Dolor</strong></small>
</div>
</div>
</div>

<!-- Quote 2 -->
<div class="item">
<div class="row">
<div class="col-sm-12">
<p>&ldquo;Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.&rdquo;</p>
<small><strong>Fringilla A., Vulputate Sit</strong></small>
</div>
</div>
</div>

<!-- Quote 3 -->
<div class="item">
<div class="row">
<div class="col-sm-12">
<p>&ldquo;Aenean lacinia bibendum nulla sed consectetur. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Maecenas faucibus mollis interdum. Cras mattis consectetur purus sit amet fermentum.&rdquo;</p>
<small><strong>Aenean A., Justo Cras</strong></small>
</div>
</div>
</div>

</div>

</div>
</div>
</div>
</div>

</div>
</div>
</div>
</div>
</section>

<!-- Bootstrap core JavaScript-->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.bundle.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
//carousel options
$('#quote-carousel').carousel({
pause: true,
interval: 10000,
});
});
</script>

最佳答案

轮播元素的类名称是 carousel-item 而不是 item。所以你应该改变每一个

<div class="item"> ...

进入

<div class="carousel-item">
<小时/>

Working Fiddle

Carousel Reference - Bootstrap

关于javascript - 从 CDN 加载的 Bootstrap Carousel 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48390098/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com