当前位置:网站首页>Swiper rotates pictures and plays background music
Swiper rotates pictures and plays background music
2022-07-30 18:32:00 【letisgo5】
需求:Rotate the pictures in the folder on the browser,并播放音乐!!!
I also found it online at first,All kinds of charges so I thought of a whole,Currently, only carousel and playing music are implemented
效果图: Currently only supports click to start,Then start playing music and carousel pictures

代码(图片与html在同一目录,If it is not in the same directory, it needs to be adjustedsrc图片路径)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Swiper demo</title>
<!-- Link Swiper's CSS -->
<link href="https://cdn.bootcss.com/Swiper/4.3.0/css/swiper.min.css" rel="stylesheet">
<!-- Demo styles -->
<style>
html, body {
position: relative;
width: 100%;
height: 100%;
}
body {
margin: 0;
padding: 0;
}
.m-swiper-container{
width: 100%;}
.m-swiper-slide{
display: block; background-size: 100% 100%;}
.m-swiper-img{
width: 100%;}
</style>
</head>
<body>
<!--bgm-->
<audio id="myAudio" src="http://music.163.com/song/media/outer/url?id=1901371647.mp3" controls="controls" autoplay loop="true" hidden="true"></audio>
<button id="goBut">GO!!!!!</button>
<!-- Swiper -->
<div class="swiper-container m-swiper-container" id="m-swiper-container">
<div class="swiper-wrapper" id="m-swiper-wrapper"></div>
</div>
<!-- Swiper JS -->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/Swiper/4.3.0/js/swiper.min.js"></script>
<!-- Initialize Swiper -->
<script>
var hdfiles = ['1.png','2.png','3.png'];
$("#goBut").click(function () {
vMP3 = document.getElementById("myAudio");
vMP3.play();
document.getElementById("goBut").style.display = "none";
var swiperWrapper = $('#m-swiper-wrapper');
var html = '';
for (var i = 0; i < hdfiles.length; i++) {
html += '<a class="swiper-slide m-swiper-slide">' +
'<img src="' + hdfiles[i] + '" class="m-swiper-img">' +
'</a>';
}
swiperWrapper.html(html);
var swiper = new Swiper('#m-swiper-container', {
speed:300,
autoplay : {
delay:3000
},
loop: true
});
});
</script>
</body>
边栏推荐
- The use of terminal split screen tool Terminalx
- Application of time series database in the field of ship risk management
- Recommendation | People who are kind to you, don't repay them by inviting them to eat
- Pytorch foundation -- tensorboard use (1)
- OneFlow源码解析:Op、Kernel与解释器
- Codeblocks + Widgets 创建窗口代码分析
- After 23 years of operation, the former "China's largest e-commerce website" has turned yellow...
- 网络基础(三)01-网络的基础概念——URL地址组成之协议、主机地址、路径和参数&127.0.0.1本地回环地址& 查看网址IP地址并访问之ping空格+网址&netstat -anb查看本机占用端口
- while,do while,for循环语句
- MYSQL (Basic) - An article takes you into the wonderful world of MYSQL
猜你喜欢

WeChat Mini Program Cloud Development | Urban Information Management

针不戳,数据库性能优化八大方案。

Immersive experience iFLYTEK 2022 Consumer Expo "Official Designated Product"

【HMS core】【ML Kit】机器学习服务常见问题FAQ(二)

Meta元宇宙部门第二季度亏损28亿!仍要继续押注?元宇宙发展尚未看到出路!

cocos creater 热更重启导致崩溃

Mongo for infrastructure

中集世联达飞瞳全球工业人工智能AI领军者,全球顶尖AI核心技术高泛化性高鲁棒性稀疏样本持续学习,工业级高性能成熟AI产品规模应用

图解LeetCode——11. 盛最多水的容器(难度:中等)

轻量级网络 ESPNetv2
随机推荐
ByteArrayInputStream class source code analysis
3D机器视觉厂商的场景争夺战役
使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
requet.getHeader("token") is null
Recommended Books | Recommend 3 database books with rave reviews
猎豹移动终于递交年报:年营收7.85亿 腾讯持股16.6%
Scrapy框架介绍
MySQL——基础知识
中集世联达工业级成熟航运港口人工智能AI产品规模化应用,打造新一代高效能智慧港口和创新数字港口,全球港航人工智能能领军者中集飞瞳
scrapy基本使用
Multiple instances of mysql
软件测试13年从业经验的前辈,总结的5条测试就业建议....
轻量级网络 ESPNetv2
LeetCode Exercise - Two Questions About Finding Sum of Array Elements
Critical Reviews | 南农邹建文组综述全球农田土壤抗生素与耐药基因分布
CCNA-ACL(访问控制列表)标准ACL 扩展ACL 命名ACL
【开发者必看】【push kit】推送服务典型问题合集3
中集世联达飞瞳全球工业人工智能AI领军者,全球顶尖AI核心技术高泛化性高鲁棒性稀疏样本持续学习,工业级高性能成熟AI产品规模应用
【Prometheus】Prometheus联邦的一次优化记录[续]
ESP8266-Arduino编程实例-BMP180气压温度传感器驱动