图片/图形

纯CSS3百叶窗式切换轮播图特效

阿里云


这是一款使用纯 CSS3 制作的百叶窗式切换轮播图特效。该特效使用背景图片来制作,在轮播图切换时,通过一组 div 元素来制作百叶窗效果,非常的炫酷。

HTML 结构

该轮播图特效中使用了 6 张背景图片,HTML 结构如下:

也想出现在这里?联系我们
创客主机
  1. <div class="slider">
  2.   <div class="captions">
  3.     <div class="c1">duzy fiat</div>
  4.     <div class="c2">syrenka</div>
  5.     <div class="c3">wartburg</div>
  6.     <div class="c4">warszawa</div>
  7.     <div class="c5">wolga</div>
  8.     <div class="c6">polonez</div>
  9.   </div>
  10.   <div class="img img1">
  11.     <div class="frag frag1"></div>
  12.     <div class="frag frag2"></div>
  13.     <div class="frag frag3"></div>
  14.     <div class="frag frag4"></div>
  15.     <div class="frag frag5"></div>
  16.     <div class="frag frag6"></div>
  17.   </div>
  18.   <div class="img img2">
  19.     <div class="frag frag1"></div>
  20.     <div class="frag frag2"></div>
  21.     <div class="frag frag3"></div>
  22.     <div class="frag frag4"></div>
  23.     <div class="frag frag5"></div>
  24.     <div class="frag frag6"></div>
  25.   </div>
  26.   <div class="img img3">
  27.     <div class="frag frag1"></div>
  28.     <div class="frag frag2"></div>
  29.     <div class="frag frag3"></div>
  30.     <div class="frag frag4"></div>
  31.     <div class="frag frag5"></div>
  32.     <div class="frag frag6"></div>
  33.   </div>
  34.   <div class="img img4">
  35.     <div class="frag frag1"></div>
  36.     <div class="frag frag2"></div>
  37.     <div class="frag frag3"></div>
  38.     <div class="frag frag4"></div>
  39.     <div class="frag frag5"></div>
  40.     <div class="frag frag6"></div>
  41.   </div>
  42.   <div class="img img5">
  43.     <div class="frag frag1"></div>
  44.     <div class="frag frag2"></div>
  45.     <div class="frag frag3"></div>
  46.     <div class="frag frag4"></div>
  47.     <div class="frag frag5"></div>
  48.     <div class="frag frag6"></div>
  49.   </div>
  50.   <div class="img img6">
  51.     <div class="frag frag1"></div>
  52.     <div class="frag frag2"></div>
  53.     <div class="frag frag3"></div>
  54.     <div class="frag frag4"></div>
  55.     <div class="frag frag5"></div>
  56.     <div class="frag frag6"></div>
  57.   </div>
  58. </div>

另外使用 6 个 Radio 按钮作为轮播图的切换按钮:

  1. <input type="radio" name="slides" id="slide1" checked>
  2. <input type="radio" name="slides" id="slide2">
  3. <input type="radio" name="slides" id="slide3">
  4. <input type="radio" name="slides" id="slide4">
  5. <input type="radio" name="slides" id="slide5">
  6. <input type="radio" name="slides" id="slide6">

CSS 样式

轮播图的基本 CSS 样式如下:

  1. .slider, .img {
  2.   width: inherit;
  3.   height: inherit;
  4. }
  5. .slider {
  6.   position: relative;
  7.   overflow: hidden;
  8.   background-color: #000;
  9.   border: 8px solid #eee;
  10.   border-radius: 5px;
  11.   box-shadow: 0 7px 20px rgba(0,0,0,.5);
  12. }
  13. .img {
  14.   position: absolute;
  15.   margin-left: -8px;
  16.   perspective: 500px;
  17. }
  18. .frag {
  19.   width: 150px;
  20.   height: inherit;
  21.   float: left;
  22.   opacity: 0;
  23.   z-index: 0;
  24.   transform-origin: center right;
  25.   transform: rotateY(90deg) translateZ(100px) scale(1.5);
  26.   transition: transform .6s, opacity .6s, -webkit-filter 2s ease-out;
  27.   -webkit-filter: saturate(0) blur(10px) brightness(.6) contrast(4);
  28. }
  29. .img .frag2 {
  30.   background-position: -150px 0;
  31.   transition-delay: .2s;
  32. }
  33. .img .frag3 {
  34.   background-position: -300px 0;
  35.   transition-delay: .4s;
  36. }
  37. .img .frag4 {
  38.   background-position: -450px 0;
  39.   transition-delay: .6s;
  40. }
  41. .img .frag5 {
  42.   background-position: -600px 0;
  43.   transition-delay: .8s;
  44. }
  45. .img .frag6 {
  46.   background-position: -750px 0;
  47.   transition-delay: 1s;
  48. }

轮播图中使用的背景图片样式如下:

  1. .img1 .frag { background-image: url(1.jpg) }
  2. .img2 .frag { background-image: url(2.jpg) }
  3. .img3 .frag { background-image: url(3.jpg) }
  4. .img4 .frag { background-image: url(4.jpg) }
  5. .img5 .frag { background-image: url(5.jpg) }
  6. .img6 .frag { background-image: url(6.jpg) }

轮播图控制按钮的 CSS 样式如下:

  1. #slide1:checked ~ .slider .img1 .frag, #slide2:checked ~ .slider .img2 .frag, #slide3:checked ~ .slider .img3 .frag, #slide4:checked ~ .slider .img4 .frag, #slide5:checked ~ .slider .img5 .frag, #slide6:checked ~ .slider .img6 .frag {
  2.   transform: rotateY(0) translateZ(0) scale(1);
  3.   -webkit-filter: saturate(1) blur(0) brightness(1) contrast(1);
  4.   opacity: 1;
  5.   z-index: 1;
  6. }
  7.  
  8. .controls {
  9.   position: absolute;
  10.   bottom: -50px;
  11.   left: 50%;
  12.   margin-left: -115px; /*(6elem30px+5el10px)/2=115px*/
  13. }
  14.  
  15. .controls label {
  16.   display: block;
  17.   height: 10px;
  18.   width: 30px;
  19.   float: left;
  20.   background-color: #000;
  21.   margin-right: 10px;
  22.   cursor: pointer;
  23.   opacity: .2;
  24.   transition: opacity .5s;
  25. }
  26.  
  27. .controls label:hover, .side-controls label:hover, 
  28. #slide1:checked ~ .controls label:nth-of-type(1), 
  29. #slide2:checked ~ .controls label:nth-of-type(2), 
  30. #slide3:checked ~ .controls label:nth-of-type(3), 
  31. #slide4:checked ~ .controls label:nth-of-type(4), 
  32. #slide5:checked ~ .controls label:nth-of-type(5), 
  33. #slide6:checked ~ .controls label:nth-of-type(6) { opacity: .8; }
  34.  
  35. .side-controls label {
  36.   position: absolute;
  37.   display: block;
  38.   border-top: 30px solid transparent;
  39.   border-bottom: 30px solid transparent;
  40.   top: 50%;
  41.   margin-top: -15px;
  42.   cursor: pointer;
  43.   opacity: .2;
  44.   transition: opacity .5s;
  45. }
  46.  
  47. #slide1:checked ~ .side-controls label:nth-of-type(6), 
  48. #slide2:checked ~ .side-controls label:nth-of-type(1), 
  49. #slide3:checked ~ .side-controls label:nth-of-type(2), 
  50. #slide4:checked ~ .side-controls label:nth-of-type(3), 
  51. #slide5:checked ~ .side-controls label:nth-of-type(4), 
  52. #slide6:checked ~ .side-controls label:nth-of-type(5) {
  53.   left: -40px;
  54.   border-right: 40px solid #000;
  55. }
  56.  
  57. #slide1:checked ~ .side-controls label:nth-of-type(2), 
  58. #slide2:checked ~ .side-controls label:nth-of-type(3), 
  59. #slide3:checked ~ .side-controls label:nth-of-type(4), 
  60. #slide4:checked ~ .side-controls label:nth-of-type(5), 
  61. #slide5:checked ~ .side-controls label:nth-of-type(6), 
  62. #slide6:checked ~ .side-controls label:nth-of-type(1) {
  63.   right: -40px;
  64.   border-left: 40px solid #000;
  65. }
  66.  
  67. #slide2:checked ~ .slider .captions .c2, 
  68. #slide1:checked ~ .slider .captions .c1, 
  69. #slide3:checked ~ .slider .captions .c3, 
  70. #slide4:checked ~ .slider .captions .c4, 
  71. #slide5:checked ~ .slider .captions .c5, 
  72. #slide6:checked ~ .slider .captions .c6 { text-shadow: 0 0 0 rgba(255,255,255,.9) }

最后为图片标题设置 CSS 样式:

  1. .captions > div {
  2.   position: absolute;
  3.   right: 20px;
  4.   bottom: 7px;
  5.   color: transparent;
  6.   text-shadow: 0 0 60px transparent;
  7.   font-size: 3em;
  8.   z-index: 1;
  9.   text-transform: uppercase;
  10.   transition: text-shadow 2s;
  11. }

Github 地址:https://github.com/andrzejbajuk79/slider-pure-css

纯 CSS3 百叶窗式切换轮播图特效

已有 462 人购买
  • vdv8
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!