HTML结构
该轮播图特效中使用了6张背景图片,HTML结构如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | < div class = "slider" > < div class = "captions" > < div class = "c1" >duzy fiat</ div > < div class = "c2" >syrenka</ div > < div class = "c3" >wartburg</ div > < div class = "c4" >warszawa</ div > < div class = "c5" >wolga</ div > < div class = "c6" >polonez</ div > </ div > < div class = "img img1" > < div class = "frag frag1" ></ div > < div class = "frag frag2" ></ div > < div class = "frag frag3" ></ div > < div class = "frag frag4" ></ div > < div class = "frag frag5" ></ div > < div class = "frag frag6" ></ div > </ div > < div class = "img img2" > < div class = "frag frag1" ></ div > < div class = "frag frag2" ></ div > < div class = "frag frag3" ></ div > < div class = "frag frag4" ></ div > < div class = "frag frag5" ></ div > < div class = "frag frag6" ></ div > </ div > < div class = "img img3" > < div class = "frag frag1" ></ div > < div class = "frag frag2" ></ div > < div class = "frag frag3" ></ div > < div class = "frag frag4" ></ div > < div class = "frag frag5" ></ div > < div class = "frag frag6" ></ div > </ div > < div class = "img img4" > < div class = "frag frag1" ></ div > < div class = "frag frag2" ></ div > < div class = "frag frag3" ></ div > < div class = "frag frag4" ></ div > < div class = "frag frag5" ></ div > < div class = "frag frag6" ></ div > </ div > < div class = "img img5" > < div class = "frag frag1" ></ div > < div class = "frag frag2" ></ div > < div class = "frag frag3" ></ div > < div class = "frag frag4" ></ div > < div class = "frag frag5" ></ div > < div class = "frag frag6" ></ div > </ div > < div class = "img img6" > < div class = "frag frag1" ></ div > < div class = "frag frag2" ></ div > < div class = "frag frag3" ></ div > < div class = "frag frag4" ></ div > < div class = "frag frag5" ></ div > < div class = "frag frag6" ></ div > </ div > </ div > |
另外使用6个Radio按钮作为轮播图的切换按钮:
1 2 3 4 5 6 | < input type = "radio" name = "slides" id = "slide1" checked> < input type = "radio" name = "slides" id = "slide2" > < input type = "radio" name = "slides" id = "slide3" > < input type = "radio" name = "slides" id = "slide4" > < input type = "radio" name = "slides" id = "slide5" > < input type = "radio" name = "slides" id = "slide6" > |
CSS样式
轮播图的基本CSS样式如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | .slider, .img { width : inherit; height : inherit; } .slider { position : relative ; overflow : hidden ; background-color : #000 ; border : 8px solid #eee ; border-radius: 5px ; box-shadow: 0 7px 20px rgba( 0 , 0 , 0 ,. 5 ); } .img { position : absolute ; margin-left : -8px ; perspective: 500px ; } .frag { width : 150px ; height : inherit; float : left ; opacity: 0 ; z-index : 0 ; transform-origin: center right ; transform: rotateY( 90 deg) translateZ( 100px ) scale( 1.5 ); transition: transform . 6 s, opacity . 6 s, -webkit-filter 2 s ease-out; -webkit-filter: saturate( 0 ) blur( 10px ) brightness(. 6 ) contrast( 4 ); } .img .frag 2 { background-position : -150px 0 ; transition-delay: . 2 s; } .img .frag 3 { background-position : -300px 0 ; transition-delay: . 4 s; } .img .frag 4 { background-position : -450px 0 ; transition-delay: . 6 s; } .img .frag 5 { background-position : -600px 0 ; transition-delay: . 8 s; } .img .frag 6 { background-position : -750px 0 ; transition-delay: 1 s; } |
轮播图中使用的背景图片样式如下:
1 2 3 4 5 6 | .img 1 .frag { background-image : url ( 1 .jpg) } .img 2 .frag { background-image : url ( 2 .jpg) } .img 3 .frag { background-image : url ( 3 .jpg) } .img 4 .frag { background-image : url ( 4 .jpg) } .img 5 .frag { background-image : url ( 5 .jpg) } .img 6 .frag { background-image : url ( 6 .jpg) } |
轮播图控制按钮的CSS样式如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #slide 1: checked ~ .slider .img 1 .frag, #slide 2: checked ~ .slider .img 2 .frag, #slide 3: checked ~ .slider .img 3 .frag, #slide 4: checked ~ .slider .img 4 .frag, #slide 5: checked ~ .slider .img 5 .frag, #slide 6: checked ~ .slider .img 6 .frag { transform: rotateY( 0 ) translateZ( 0 ) scale( 1 ); -webkit-filter: saturate( 1 ) blur( 0 ) brightness( 1 ) contrast( 1 ); opacity: 1 ; z-index : 1 ; } .controls { position : absolute ; bottom : -50px ; left : 50% ; margin-left : -115px ; /*(6elem30px+5el10px)/2=115px*/ } .controls label { display : block ; height : 10px ; width : 30px ; float : left ; background-color : #000 ; margin-right : 10px ; cursor : pointer ; opacity: . 2 ; transition: opacity . 5 s; } .controls label:hover, .side-controls label:hover, #slide 1: checked ~ .controls label:nth-of-type( 1 ), #slide 2: checked ~ .controls label:nth-of-type( 2 ), #slide 3: checked ~ .controls label:nth-of-type( 3 ), #slide 4: checked ~ .controls label:nth-of-type( 4 ), #slide 5: checked ~ .controls label:nth-of-type( 5 ), #slide 6: checked ~ .controls label:nth-of-type( 6 ) { opacity: . 8 ; } .side-controls label { position : absolute ; display : block ; border-top : 30px solid transparent ; border-bottom : 30px solid transparent ; top : 50% ; margin-top : -15px ; cursor : pointer ; opacity: . 2 ; transition: opacity . 5 s; } #slide 1: checked ~ .side-controls label:nth-of-type( 6 ), #slide 2: checked ~ .side-controls label:nth-of-type( 1 ), #slide 3: checked ~ .side-controls label:nth-of-type( 2 ), #slide 4: checked ~ .side-controls label:nth-of-type( 3 ), #slide 5: checked ~ .side-controls label:nth-of-type( 4 ), #slide 6: checked ~ .side-controls label:nth-of-type( 5 ) { left : -40px ; border-right : 40px solid #000 ; } #slide 1: checked ~ .side-controls label:nth-of-type( 2 ), #slide 2: checked ~ .side-controls label:nth-of-type( 3 ), #slide 3: checked ~ .side-controls label:nth-of-type( 4 ), #slide 4: checked ~ .side-controls label:nth-of-type( 5 ), #slide 5: checked ~ .side-controls label:nth-of-type( 6 ), #slide 6: checked ~ .side-controls label:nth-of-type( 1 ) { right : -40px ; 特别申明:
|