鱼C论坛

 找回密码
 立即注册
查看: 3384|回复: 1

[学习笔记] 鼠标滑动切换图片

[复制链接]
发表于 2020-2-24 16:34:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 wp231957 于 2020-2-24 19:32 编辑
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>演示鼠标滑动切换图像的页面</title>
  6.         <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script>
  7.         <style>
  8.                 .circle ul li
  9.                                          {
  10.                                                 list-style:none;
  11.                                                 float:left;
  12.                                                         width:40px;
  13.                                                         height:40px;
  14.                                                         background:orange;
  15.                                                         margin-left:5px;
  16.                                                         border-radius: 50%;
  17.                                        
  18.                                           }
  19.                                           .circle ul
  20.                                           {
  21.                                                  overflow:hidden;
  22.                                                          height:50px;
  23.                                                          margin-top:20px;
  24.                                                          margin-left:120px;
  25.                                           }
  26.                                           .circle
  27.                                           {
  28.                                                  position:absolute;
  29.                                                          bottom:200px;
  30.                                                          left:20%;
  31.                                                          width:400px;
  32.                                                          height:400px;
  33.                                                          border:1px solid #000;
  34.                                           }
  35.                                           .circle ul li.current
  36.                                           {
  37.                                                  background:red;

  38.                                           }
  39.         </style>
  40. </head>
  41. <body>
  42.      <div class="circle" id="circle">
  43.             <img width=400px  height=400px id="img01" src="/pic/2111.png"></img>
  44.         <ul>
  45.             <li class="current"></li>
  46.             <li></li>
  47.             <li></li>
  48.             <li></li>
  49.                         <li></li>
  50.         </ul>
  51.     </div>
  52. <script>
  53.     imglist=["2111.png","2112.png","2113.png","2114.png","2115.png"];
  54.     $("#circle ul li").mouseover(function()
  55.     {
  56.         $(this).hover(function()
  57.         {
  58.                     //console.log($(this).index());
  59.             $(this).css('background', 'red');
  60.                         $("#img01").attr('src',"/pic/"+imglist[$(this).index()]);
  61.         }, function()
  62.         {
  63.             $(this).css('background', 'orange');
  64.         });
  65.     });
  66. </script>
  67. </body>
  68. </html>
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-2-24 19:34:49 | 显示全部楼层
示例图片
演示1.png
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-2 19:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表