Skip to content

Commit d486c2a

Browse files
authored
show only one
1 parent 98988fd commit d486c2a

File tree

1 file changed

+91
-17
lines changed

1 file changed

+91
-17
lines changed

CN/modules/ROOT/pages/v4.6/dynamic.adoc

Lines changed: 91 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
<div class="swiper-slide">
1717
<img src="https://picsum.photos/800/400?random=3" alt="风景图片3">
1818
</div>
19+
<div class="swiper-slide">
20+
<img src="https://picsum.photos/800/400?random=4" alt="风景图片4">
21+
</div>
22+
<div class="swiper-slide">
23+
<img src="https://picsum.photos/800/400?random=5" alt="风景图片5">
24+
</div>
1925
</div>
2026
<!-- 分页器 -->
2127
<div class="swiper-pagination"></div>
@@ -27,80 +33,148 @@
2733
2834
<script>
2935
var swiper = new Swiper('.swiper-container', {
36+
// 确保一次只显示一张幻灯片
37+
slidesPerView: 1,
38+
slidesPerGroup: 1,
39+
spaceBetween: 0,
40+
41+
// 循环播放
3042
loop: true,
43+
44+
// 自动播放设置
3145
autoplay: {
32-
delay: 3000,
46+
delay: 4000, // 4秒切换
3347
disableOnInteraction: false,
3448
},
49+
50+
// 分页器
3551
pagination: {
3652
el: '.swiper-pagination',
3753
clickable: true,
54+
dynamicBullets: true,
3855
},
56+
57+
// 导航按钮
3958
navigation: {
4059
nextEl: '.swiper-button-next',
4160
prevEl: '.swiper-button-prev',
4261
},
62+
63+
// 切换效果 - 使用淡入淡出而不是滑动
64+
effect: 'fade',
65+
fadeEffect: {
66+
crossFade: true
67+
},
68+
69+
// 速度控制
70+
speed: 800,
4371
});
4472
</script>
4573
4674
<style>
4775
/* 容器样式 - 限制宽度不遮挡导航栏 */
4876
.image-carousel-container {
49-
max-width: 75%; /* 调整为适合的宽度 */
77+
max-width: 75%;
5078
margin: 20px auto;
5179
padding: 0 15px;
5280
}
5381
5482
.swiper-container {
5583
width: 100%;
56-
height: 350px; /* 稍微降低高度 */
84+
height: 400px;
5785
border-radius: 8px;
86+
overflow: hidden; /* 确保内容不会溢出 */
5887
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
5988
}
6089
90+
/* 确保每个幻灯片占据整个容器 */
91+
.swiper-slide {
92+
width: 100%;
93+
height: 100%;
94+
display: flex;
95+
justify-content: center;
96+
align-items: center;
97+
}
98+
6199
.swiper-slide img {
62100
width: 100%;
63101
height: 100%;
64102
object-fit: cover;
65103
border-radius: 6px;
66104
}
67105
68-
/* 响应式设计 - 在小屏幕上全宽度 */
69-
@media (max-width: 768px) {
70-
.image-carousel-container {
71-
max-width: 100%;
72-
padding: 0 10px;
73-
}
74-
75-
.swiper-container {
76-
height: 300px;
77-
}
106+
/* 淡入淡出效果增强 */
107+
.swiper-container-fade .swiper-slide {
108+
pointer-events: none;
109+
}
110+
.swiper-container-fade .swiper-slide-active {
111+
pointer-events: auto;
78112
}
79113
80-
/* 导航按钮样式调整 */
114+
/* 导航按钮样式 */
81115
.swiper-button-next,
82116
.swiper-button-prev {
83-
background-color: rgba(255,255,255,0.7);
84-
width: 40px;
85-
height: 40px;
117+
background-color: rgba(255,255,255,0.8);
118+
width: 44px;
119+
height: 44px;
86120
border-radius: 50%;
87121
color: #333;
122+
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
123+
transition: all 0.3s ease;
88124
}
89125
90126
.swiper-button-next:after,
91127
.swiper-button-prev:after {
92128
font-size: 18px;
129+
font-weight: bold;
130+
}
131+
132+
.swiper-button-next:hover,
133+
.swiper-button-prev:hover {
134+
background-color: rgba(255,255,255,0.95);
135+
transform: scale(1.05);
93136
}
94137
95138
/* 分页器样式 */
139+
.swiper-pagination {
140+
bottom: 15px !important;
141+
}
142+
96143
.swiper-pagination-bullet {
144+
width: 10px;
145+
height: 10px;
97146
background: #fff;
98147
opacity: 0.7;
148+
transition: all 0.3s ease;
99149
}
100150
101151
.swiper-pagination-bullet-active {
102152
background: #007bff;
103153
opacity: 1;
154+
transform: scale(1.2);
155+
}
156+
157+
/* 响应式设计 */
158+
@media (max-width: 768px) {
159+
.image-carousel-container {
160+
max-width: 95%;
161+
padding: 0 10px;
162+
}
163+
164+
.swiper-container {
165+
height: 300px;
166+
}
167+
168+
.swiper-button-next,
169+
.swiper-button-prev {
170+
width: 36px;
171+
height: 36px;
172+
}
173+
174+
.swiper-button-next:after,
175+
.swiper-button-prev:after {
176+
font-size: 16px;
177+
}
104178
}
105179
</style>
106180
++++

0 commit comments

Comments
 (0)