Web常用工具 二维码美化 在线压缩 JavaScript AI工具汇总网站 图片轮播插件(swiper) W3CHTML W3SCHOOL TypeScript 开源中国 51aspx github codeproject SQLBACKUP 几种排序算法比较 SQL中deny权限 MSDN下载 HttpWebRequest类 HTML5 stackoverflow ASP.NET 页生命周期概述 IIS 5.0 和 6.0 的 ASP.NET 应用程序生命周期概述 [SQL Server]视图sys.sysprocesses brnshop学习 SQL视频 Fiddler帮助文档 Sprint.Net SQLServer牛人博客 codeplex IIS官网 IE11 Developer Jquery源码视频上 Jquery源码视频下 Jquery Bugs jquery.miaov.com 正则表达式 Jquery API 1.9 Service Broker Javascript Object中的方法讲解 Microsoft webcast 微信开发接口 ECMAScript5 Underscore Jquery Bugs SQL存储过程事务嵌套 官网SQL事务锁 2345天气插件 Json数据查看 Javascript设计模式 C++ jquery-plugin-validate 博学谷(传智播客) Swift视频 IOS代码论坛 SWIFT设计模式 操作系统下载 AngularJS VueJS Nuxt Vant-UI官方文档 ASPNETCORE 前端题库 Node.js NPMjs ASPNETCORE 腾讯课堂 SwiftUI SwiftUI疑问解答 ADO.NET SMO 数字化企业网 Unicode码查询 Redis使用文档 .NET 微服务:适用于容器化 .NET 应用程序的体系结构 .NETCore5.0微软官方文档 CSS3.0 在 ASP.NET Core 中配置 Windows 身份验证 Maven使用教程 Maven Repository Thymeleaf Thymeleaf中文CSDN Spring官方文档 SpringBoot SpringData SVG在线设计工具 SVG教程01 SVG教程02 fontawesome图标库 mybatis官网 mybatis-spring中文 mysql教程 python教程 python的scrapy教程01 python的scrapy教程02 VS开发python xpath教程 腾讯向量数据库教程 JSZip浏览器内存中创建文件与文件夹 axios的使用文档 SheetJS(JS操作excel)的使用文档 极简插件官网(chrome的扩展插件) 金蝶云星空学习成长 常用接口调用 Three.js电子书 D3.js官网 anime.js官网 xlsx.js官网 若依框架 若依文档 华为数字人 MDN之JavaScript语法 百度地图API 百度地图API案例 百度地图API使用说明 Nginx中文文档 i18n Animate.css Bootstrap官网 Jquery datatables.net插件 免费SVG C#官网

huaan011

 

一个简易的轮播图效果,可以根据这个来进行完善

  1 <!doctype html>
  2 <html>
  3 <head>
  4     <style type="text/css">
  5         .container {
  6             width: 500px;
  7             height: 100px;
  8             overflow: hidden;
  9             position: relative;
 10         }
 11             .container ul {
 12                 width: 50000px; /** 越大越好,也可以精确的计算出来,就是所有轮播图的总宽度 **/
 13                 margin: 0px;
 14                 padding: 0px;
 15                 position: absolute;
 16                 border:0px;
 17                 font-size:0px;
 18             }
 19             .container ul::after {
 20                 display: block;
 21                 clear: both;
 22             }
 23             .containerItem {
 24                 float: left;
 25                 width: 500px;
 26                 height: 100px;
 27                 line-height:100px;
 28                 text-align:center;
 29                 font-size:30px;
 30                 color:#ffffff;
 31                 display: inline-block;
 32                 background-color: aqua;
 33                 border:0px;
 34             }
 35         .container .prev, .container .next {
 36             padding: 0px;
 37             margin:0px;
 38             position: absolute;
 39             width: 30px;
 40             height: 40px;
 41             line-height:40px;
 42             background-color: #000000;
 43             opacity: 0.5;
 44             color: #ffffff;
 45             text-align: center;
 46             top: 50%;
 47             margin-top: -20px;
 48 
 49         }
 50             .container .prev:hover, .container .next:hover{
 51                 cursor:pointer;
 52                 cursor:hand;
 53             }
 54             .container .prev {
 55                 left: 0px;
 56             }
 57         .container .next{
 58             right:0px;
 59         }
 60         .containerCircle{
 61             position:absolute;
 62             padding:0px;
 63             margin:0px;
 64             bottom:0px;
 65             text-align:center;
 66             width:100%;
 67             height:20px;
 68             line-height:20px;
 69             background-color:#000000;
 70             opacity:0.5;
 71             font-size:0px;
 72         }
 73         .containerCircle span{
 74             border:0px;
 75             display:inline-block;
 76             vertical-align:middle;
 77             width:10px;
 78             aspect-ratio:1 / 1;
 79             background-color:#ffffff;
 80             border-radius:50%;
 81             margin:0px 3px;
 82         }
 83        .containerCircle span:hover{
 84            cursor:pointer;
 85            cursor:hand;
 86        }
 87     </style>
 88     
 89 </head>
 90 
 91 <body>
 92     <div class="container">
 93         <ul id="wheelimage">
 94             <li class="containerItem" style="background-color:#4cff00">1</li>
 95             <li class="containerItem" style="background-color:#ff6a00">2</li>
 96             <li class="containerItem" style="background-color:#bf1e1e">3</li>
 97             <li class="containerItem" style="background-color:#953fae">4</li>
 98             <li class="containerItem" style="background-color:#32b213">5</li>
 99         </ul>
100         <span class="prev" onclick="wheelImage.left()"><</span>
101         <span class="next" onclick="wheelImage.right()">></span>
102         <div class="containerCircle">
103             <span onclick="wheelImage.moveto(0)"></span>
104             <span onclick="wheelImage.moveto(1)"></span>
105             <span onclick="wheelImage.moveto(2)"></span>
106             <span onclick="wheelImage.moveto(3)"></span>
107             <span onclick="wheelImage.moveto(4)"></span>
108         </div>
109     </div>
110     <script>
111         let wheelImage = (function () {
112             let start = 0;
113             let maxCount = 5; //轮播的总个数
114             let currentIndex = 0;
115             let _width = 500; //每个轮播图片的宽度
116             let wheelimageObj = document.getElementById("wheelimage");
117             let anim = function () { };
118             anim.prototype.move = function () {
119                 start = -currentIndex * _width;
120                 wheelimageObj.style.left = start + "px";
121             }
122             anim.prototype.left = function () {
123                 if (currentIndex >= maxCount - 1) { currentIndex = maxCount - 1; } else { currentIndex += 1; }
124                 this.move();
125             }
126             anim.prototype.right = function () {
127                 if (currentIndex <= 0) { currentIndex = 0; } else { currentIndex -= 1; }
128                 this.move();
129             }
130             anim.prototype.moveto = function (idx) {
131                 currentIndex = idx;
132                 this.move();
133             }
134             return new anim();
135         })();
136     </script>
137 </body>
138 </html>

效果图如下:

如果还需要进一步的效果图,可以完善上面的代码,我这只是提供了一个思路。供互相学习之用。

 

posted on 2025-07-09 10:21  华安  阅读(10)  评论(0)    收藏  举报

导航