File tree 8 files changed +262
-299
lines changed
8 files changed +262
-299
lines changed Original file line number Diff line number Diff line change 7
7
margin : auto; /* 在水平方向自动调整外边距,实现居中 */
8
8
}
9
9
10
+ /* 其他样式保持不变 */
11
+
10
12
.carousel .slides {
11
13
display : flex;
12
14
padding : 0 ;
Load Diff Large diffs are not rendered by default.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 27
27
}
28
28
} ) ;
29
29
30
- // CAROUSEL LOGIC
31
- ( function carouselLogic ( $ ) {
32
- var currentSlide = 0 ;
33
- var slides = $ ( '.slides img' ) ;
34
- var dots = $ ( '.nav-dots .dot a' ) ;
35
- var arrowLeft = $ ( '.arrow-left a' ) ;
36
- var arrowRight = $ ( '.arrow-right a' ) ;
30
+ } ) ( window . jQuery ) ;
37
31
38
- function showSlide ( n ) {
39
- if ( n >= slides . length ) {
40
- n = 0 ;
41
- }
42
- if ( n < 0 ) {
43
- n = slides . length - 1 ;
44
- }
45
32
46
- slides . each ( function ( index ) {
47
- $ ( this ) . css ( 'display' , 'none' ) ;
48
- } ) ;
49
- slides . eq ( n ) . css ( 'display' , 'block' ) ;
50
-
51
- // 更新导航点的激活状态
52
- dots . each ( function ( index ) {
53
- $ ( this ) . removeClass ( 'active' ) ;
54
- } ) ;
55
- dots . eq ( n ) . addClass ( 'active' ) ;
56
- }
57
-
58
- function updateDots ( ) {
59
- dots . each ( function ( index ) {
60
- $ ( this ) . on ( 'click' , function ( ) {
61
- showSlide ( index ) ;
62
- } ) ;
63
- } ) ;
64
- }
65
-
66
- arrowLeft . on ( 'click' , function ( ) {
67
- showSlide ( currentSlide -= 1 ) ;
68
- } ) ;
69
-
70
- arrowRight . on ( 'click' , function ( ) {
71
- showSlide ( currentSlide += 1 ) ;
72
- } ) ;
73
-
74
- showSlide ( currentSlide ) ;
75
- updateDots ( ) ;
76
- } ) ( jQuery ) ;
77
-
78
- } ) ( window . jQuery ) ;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments