当前位置:网站首页>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>
边栏推荐
- 【Swords Offer】Swords Offer 17. Print n digits from 1 to the largest
- 第4章 控制执行流程
- Fixed asset visualization intelligent management system
- 【HMS core】【ML Kit】机器学习服务常见问题FAQ(二)
- ROS 环境使用第三方动态链接库(.so)文件
- 【HarmonyOS】【ARK UI】HarmonyOS ets语言怎么实现双击返回键退出
- 网络基础(二)-Web服务器-简介——WampServer集成服务器软件之Apache+MySQL软件安装流程 & netstat -an之检测计算机的端口是否占用
- SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)
- 原生js系列
- One year after graduation, I was engaged in software testing and won 11.5k. I didn't lose face to the post-98 generation...
猜你喜欢

ESP8266-Arduino programming example-HC-SR04 ultrasonic sensor driver

6块钱1斤,日本公司为何来中国收烟头?

EMC VPLEX VS2 SPS电池更换详细探讨

Critical Reviews | 南农邹建文组综述全球农田土壤抗生素与耐药基因分布

【HMS core】【FAQ】Account Kit、MDM能力、push Kit典型问题合集6

Mysql execution principle analysis

A senior with 13 years of experience in software testing, summed up 5 test employment suggestions....

ESP8266-Arduino编程实例-BMP180气压温度传感器驱动

毕业1年从事软件测试拿下11.5k,没有给98后丢脸吧...

ctf.show_web5
随机推荐
Critical Reviews | A review of the global distribution of antibiotics and resistance genes in farmland soil by Nannong Zou Jianwen's group
ESP8266-Arduino编程实例-DS18B20温度传感器驱动
网络基础(三)01-网络的基础概念——URL地址组成之协议、主机地址、路径和参数&127.0.0.1本地回环地址& 查看网址IP地址并访问之ping空格+网址&netstat -anb查看本机占用端口
Codeblocks + Widgets 创建窗口代码分析
Basic use of scrapy
网络基础(二)-Web服务器-简介——WampServer集成服务器软件之Apache+MySQL软件安装流程 & netstat -an之检测计算机的端口是否占用
DM8:单库单实例搭建本地数据守护服务
DevEco Studio3.0下载失败,提示An unknown error occurred
自然语言处理nltk
强啊,点赞业务缓存设计优化探索之路。
设计消息队列存储消息数据的 MySQL 表格
Presto 中 lookUp Join的实现
攻防世界web-Cat
Redis for infrastructure
[Use of Qt Designer tool]
原生js系列
【AGC】构建服务1-云函数示例
Quickly build an e-commerce platform based on Amazon cloud technology serverless service - performance
OSPF详解(3)
Fixed asset visualization intelligent management system