我正在尝试创建一个将图像和视频组合在一起的滑块.
我尝试使用引导程序来实现,但是我没有这样做.
这是下面的代码
<div id="carousel-slider" class="carousel slide carousel-fade" data-ride="carousel">
<!--Indicators-->
<ol class="carousel-indicators">
<li data-target="#carousel-slider" data-slide-to="0" class="active"></li>
<li data-target="#carousel-slider" data-slide-to="1"></li>
<li data-target="#carousel-slider" data-slide-to="2"></li>
</ol>
<!--Indicators-->
<!--Slides-->
<div class="carousel-inner" role="listBox">
<!--First slide-->
<div class="carousel-item active">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(130).jpg" alt="First slide">
</div>
<!--/First slide-->
<!--Second slide-->
<div class="carousel-item">
<video src="./video/video1.mp4" autoplay poster="./images/boardwalk.jpg"></video>
</div>
<!--/Second slide-->
<!--Third slide-->
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(70).jpg" alt="Third slide">
</div>
<!--/Third slide-->
</div>
</div>
I need three slides,with two image slides,and one to be a video slide,that changes every 15s.
最佳答案
我真的很喜欢http://kenwheeler.github.io/slick/的jquery滑块.我认为这对您有很大帮助.
原文链接:https://www.f2er.com/html/530394.html我在下面为您提供了一个示例:
//Initialize your slider in your script file
$("#carousel-slider").slick({
arrows: false,infinite: true,slidesToShow: 1,slidesToScroll: 1,autoplay: true,autoplaySpeed: 1500,mobileFirst: true
});
<!-- HTML -->
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.css" />
</head>
<div id="carousel-slider">
<div>
<img style="width:100%; height:100%;" class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(130).jpg" alt="First slide">
</div>
<div>
<video style="width:100%; height:100%;" src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" autoplay></video>
</div>
<div>
<img style="width:100%; height:100%;" class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(70).jpg" alt="Third slide">
</div>
</div>
<!-- Calling jQuery -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<!-- Calling Slick Library -->
<script src="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>
您可以将“ autoplaySpeed”更改为您想要更改的任何间隔.