首页 技术 正文
技术 2022年11月7日
0 收藏 539 点赞 1,056 浏览 3053 个字
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title> 飛天网事–纯CSS代码实现图片轮播 </title>
  5. <meta charset=”utf-8″ />
  6. <meta name=”description” content=”飛天网事,WEB前端开发,纯css3代码图片轮播,HTML5+CSS3精彩案例” />
  7. <meta name=”keywords” content=”飛天网事,WEB前端开发,HTML5,CSS3,jQuery,” />
  8. <meta name=”author” content=”R.tian @eduppp.cn 2015″>
  9. <link rel=”shortcut icon”  href=”https://img.zhankr.net/4unclxoxpgn34653.gif” />
  10. <link rel=”apple-touch-icon” href=”https://img.zhankr.net/u15plrjaacf34654.gif” />
  11. <style type=”text/css”>
  12. #frame {/*———-图片轮播相框容器———-*/
  13. position: absolute; /*–绝对定位,方便子元素的定位*/
  14. width: 300px;
  15. height: 200px;
  16. overflow: hidden;/*–相框作用,只显示一个图片—*/
  17. border-radius:5px;
  18. }
  19. #dis {/*–绝对定位方便li图片简介的自动分布定位—*/
  20. position: absolute;
  21. left: -50px;
  22. top: -10px;
  23. opacity: 0.5;
  24. }
  25. #dis li {
  26. display: inline-block;
  27. width: 200px;
  28. height: 20px;
  29. margin: 0 50px;
  30. float: left;
  31. text-align: center;
  32. color: #fff;
  33. border-radius: 10px;
  34. background: #000;
  35. }
  36. #photos img {
  37. float: left;
  38. width:300px;
  39. height:200px;
  40. }
  41. #photos {/*—设置总的图片宽度–通过位移来达到轮播效果—-*/
  42. position: absolute;z-index:9px;
  43. width: calc(300px * 5);/*—修改图片数量的话需要修改下面的动画参数*/
  44. }
  45. .play{
  46. animation: ma 20s ease-out infinite alternate;/**/
  47. }
  48. @keyframes ma {/*—每图片切换有两个阶段:位移切换和静置。中间的效果可以任意定制—-*/
  49. 0%,20% {        margin-left: 0px;       }
  50. 25%,40% {       margin-left: -300px;    }
  51. 45%,60% {       margin-left: -600px;    }
  52. 65%,80% {       margin-left: -900px;    }
  53. 85%,100% {      margin-left: -1200px;   }
  54. }
  55. .num{
  56. position:absolute;z-index:10;
  57. display:inline-block;
  58. right:10px;top:165px;
  59. border-radius:100%;
  60. background:#f00;
  61. width:25px;height:25px;
  62. line-height:25px;
  63. cursor:pointer;
  64. color:#fff;
  65. text-align:center;
  66. opacity:0.8;
  67. }
  68. .num:hover{background:#00f;}
  69. .num:hover,#photos:hover{animation-play-state:paused;}
  70. .num:nth-child(2){margin-right:30px}
  71. .num:nth-child(3){margin-right:60px}
  72. .num:nth-child(4){margin-right:90px}
  73. .num:nth-child(5){margin-right:120px}
  74. #a1:hover ~ #photos{animation: ma1 .5s ease-out forwards;}
  75. #a2:hover ~ #photos{animation: ma2 .5s ease-out forwards;}
  76. #a3:hover ~ #photos{animation: ma3 .5s ease-out forwards;}
  77. #a4:hover ~ #photos{animation: ma4 .5s ease-out forwards;}
  78. #a5:hover ~ #photos {animation: ma5 .5s ease-out forwards;}
  79. @keyframes ma1 {0%{margin-left:-1200px;}100%{margin-left:-0px;} }
  80. @keyframes ma2 {0%{margin-left:-1200px;}100%{margin-left:-300px;}   }
  81. @keyframes ma3 {100%{margin-left:-600px;}   }
  82. @keyframes ma4 {100%{margin-left:-900px;}   }
  83. @keyframes ma5 {100%{margin-left:-1200px;}  }
  84. </style>
  85. </head>
  86. <body>
  87. <div id=”frame” >
  88. <a id=”a1″ class=”num”>1</a>
  89. <a id=”a2″ class=”num”>2</a>
  90. <a id=”a3″ class=”num”>3</a>
  91. <a id=”a4″ class=”num”>4</a>
  92. <a id=”a5″ class=”num”>5</a>
  93. <div id=”photos” class=”play”>
  94. <img src=”https://img.zhankr.net/rjslpr3yv5n34655.jpg” >
  95. <img src=”https://img.zhankr.net/uzmokesq1sq34656.jpg” >
  96. <img src=”https://img.zhankr.net/ru1o3irxrkd34657.jpg” >
  97. <img src=”https://img.zhankr.net/ip3d1atnhez34658.jpg” >
  98. <img src=”https://img.zhankr.net/lvrg03ja3rp34659.jpg” >
  99. <ul id=”dis”>
  100. <li>中国标志性建筑:天安门</li>
  101. <li>中国标志性建筑:东方明珠</li>
  102. <li>中国标志性建筑:布达拉宫</li>
  103. <li>中国标志性建筑:长城</li>
  104. <li>中国标志性建筑:天坛</li>
  105. </ul>
  106. </div>
  107. </div>
  108. </body>
  109. </html>

《借鉴地址:http://blog.csdn.net/rtian001/article/details/48474677》

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905