TA的每日心情 | 开心 2018-8-8 03:13 |
|---|
签到天数: 1 天 [LV.1]初来乍到
|
发表于 2020-8-30 21:52:01
|
显示全部楼层
本帖最后由 喬治兄 于 2020-8-30 21:57 编辑 / Y. l6 q% P/ u; a! b5 r0 Z( d
可以考慮用這個
, g! ~9 f: x8 I4 V k! g照著套用應該是 OK 的
. }( b3 Q" P: {. M- C. L5 o
' y1 e, d' a- j) n. Q0 \3 _" G3 X/ Ehttps://www.w3schools.com/howto/ ... tryhow_js_slideshow
1 U1 N3 o1 l7 Y3 ?/ _ J- O6 T' f V1 o1 X: h# h+ Y, U0 R

x' J/ ?0 Y6 J& K' x7 J! E
# Q; L, T" y! B; t& F% ~<!DOCTYPE html>
1 j% h5 w7 r/ U- ?$ i1 J! _7 m- k<html>7 r$ }5 z! \& J0 o O
<head>4 A" x3 ]4 J' i" ?# v4 h
<meta name="viewport" content="width=device-width, initial-scale=1">
- y/ ]7 S/ |% k<style>
2 i2 k+ {6 n5 P+ l- o* {box-sizing: border-box}9 r1 ^* H7 Q& B2 D4 Z8 Y- z6 ]: L
body {font-family: Verdana, sans-serif; margin:0}
+ h& ^9 m$ \/ y v.mySlides {display: none}
; v9 w4 T, x/ bimg {vertical-align: middle;}
- k( M' w2 n- p* r
) y# o0 k* m3 J2 F/* Slideshow container */
% ?" ~4 ~+ z( F7 Y.slideshow-container {
/ j, C3 T3 H# Q' ] max-width: 1000px;
8 t+ z& H/ @1 g; ]. j( x; Y% a position: relative;8 a# Q; j6 @/ B8 T$ V) w
margin: auto;
1 e6 b1 Q1 a, c9 c3 P}* G1 W% K9 ?' P: e; Q- t
8 \( C2 v0 ~/ t S/* Next & previous buttons */
! A7 z2 I. e& R$ e.prev, .next {# S ~8 `5 S* F/ j' t+ W: I. Q1 i
cursor: pointer;
0 B4 [9 \+ N% C9 E/ v position: absolute;5 {! t6 I+ f+ Y2 b9 ?; M
top: 50%;$ G j, l+ K, W8 v' s
width: auto;
9 F& F9 E; Y+ U$ o _2 A padding: 16px;8 k/ \7 w( p$ l$ w
margin-top: -22px;
& \4 u. ^2 f/ ?& K5 K* T color: white;
# m. D1 n. Z& w# [% Q2 R% O i6 g font-weight: bold;6 G) k2 V6 k" v
font-size: 18px;
3 k m2 Y# R' L( z) R/ F& R4 c transition: 0.6s ease;/ P$ H( \. ]. A
border-radius: 0 3px 3px 0;, x5 K" g. @2 ]8 ^* R
user-select: none;6 T* |1 g" x' }3 ]
}
$ c* O9 n% d# d) `
/ C, A1 x1 L0 Z/* Position the "next button" to the right */
3 f, n8 A1 {% }.next {
# o) m4 O4 T8 R+ d right: 0;1 d, |: U2 f, }0 s& ]
border-radius: 3px 0 0 3px;8 T1 X6 l- W* H9 f) c% _& ~3 L8 x4 V
}
; k9 |0 k/ A- T- D5 ]" }0 Y3 }+ @. a% X4 w+ z8 J3 t3 V
/* On hover, add a black background color with a little bit see-through */' \$ D3 Y- Z4 a5 T# o% ?
.prev:hover, .next:hover {6 V4 `. ~9 {! z, R
background-color: rgba(0,0,0,0.8);- U: c5 U) G7 ~# ] u. n6 V1 ]
}) u0 ~( x, O; X2 }
( P( m: Q5 ]" f' I8 C
/* Caption text */
2 q& e) \ F; J( D0 f6 }.text {
2 H8 U. ?! g" D; Y* W$ e& y% E color: #f2f2f2;
$ ~( k( ~" [. o) E2 u font-size: 15px;
; ]9 I, a M: @0 M4 `: D padding: 8px 12px;
' Z7 I" S+ m0 D8 r- E! |% G% k position: absolute;5 D' w) B {2 E. [- J4 L
bottom: 8px;
9 p' v8 }8 G% [0 s width: 100%;0 q# G: x+ B& a0 v# q% x- c
text-align: center;2 z3 B) s T7 c, X5 T6 P
}
0 C/ I7 U2 p* {! t! @9 D/ x) i0 w/ m( Y8 J
/* Number text (1/3 etc) */
5 g. ? O3 b4 Q.numbertext {
6 [1 Y( I0 D3 d1 {0 [ color: #f2f2f2;& w; _! _9 o6 ^9 H" s1 Z- o
font-size: 12px;
6 @" M8 h& ?: [2 W: H( I4 a padding: 8px 12px;
+ |9 \9 `5 A- C; M! B$ P. l9 K position: absolute;0 o# r3 c6 l9 _; j |, ^
top: 0;
6 p4 A8 ]' d8 e7 u! ?) X1 z}$ X( ^! p1 B9 f- v' Z7 t; Z3 t
4 W9 S" V5 V: g" k/* The dots/bullets/indicators */
/ q/ L% Y, Y/ X! b( D.dot {4 E! W% @# g6 u* Y5 ~0 t- W
cursor: pointer;
6 X9 K0 F" \* m7 M$ B* b. E/ ~% D height: 15px;
8 X K% x* d' X) p width: 15px;9 U; D' ]4 x! R: L: v4 [' Z3 A
margin: 0 2px;
3 W7 ?' y) G D; M- c4 c background-color: #bbb;
; X- C1 s+ \& y border-radius: 50%;- G2 p, U+ y3 P# l: l/ D# Z
display: inline-block;. m% O+ U( v3 P. t/ w2 O
transition: background-color 0.6s ease;4 E9 \) \" |) E" ?- n8 p' r% x; D
}
' r! c7 a4 h" N1 _$ W6 ?: J0 X4 ^, |
.active, .dot:hover {
- r5 |7 {& ^4 a1 ?/ s background-color: #717171;
8 Z; g5 ~- C( c* z- D! A3 S}- w! J- }) L9 M) k( E; Q
' K8 h' |( A5 P# p$ U) @2 P2 j+ T! E& s/* Fading animation */
c' c- }! H- Z$ e.fade {( x- l3 F$ }2 u: a% M2 s
-webkit-animation-name: fade;& I; ]$ ~4 K6 Y9 u; Y
-webkit-animation-duration: 1.5s;
/ }8 }8 D; g. |% r( E! W2 [: ?5 W animation-name: fade;
' a7 d% | F8 @+ [( { animation-duration: 1.5s;
- V; p4 P* S. W4 v}
: L$ ^2 G! E( P) I0 Q6 Q6 X2 j9 Z7 `/ E/ V r! @1 m
@-webkit-keyframes fade {* B ~, ^ |6 n( A
from {opacity: .4}
9 |$ t8 q5 V& G0 a4 \- m* Z/ G7 b7 X to {opacity: 1}
- @0 i& O ?' C! z9 N}
V9 U& _# J% \5 y c' t: A4 {* p3 C9 O
@keyframes fade {' D7 K7 U; P$ w: C' P
from {opacity: .4}
: A' [" g F& U; X7 @0 a to {opacity: 1}
* T, e" Z# f( S: J( t}
/ o( ~' {: I6 F
5 |2 d4 b* V& V, N/* On smaller screens, decrease text size */+ @- L+ U% V6 F' M. D
@media only screen and (max-width: 300px) {
% P, U. }, p- V9 u- D! |4 q .prev, .next,.text {font-size: 11px}& L. C( N# v$ T( \+ T* t
}! W5 Q4 y3 g1 l1 L
</style>7 V- n( C7 F: a5 _2 L
</head>
3 o: l Q3 m6 Z; r. ?* {<body>
5 a; p& w7 [- t% I3 y% s) \0 Q. ]! `0 Y* e& R
<div class="slideshow-container">0 G, {9 _, z4 K8 q7 o
( |8 z0 ]4 O8 X" s# u<div class="mySlides fade">
/ Q0 l' ?, m* J8 j <div class="numbertext">1 / 3</div>6 Q, T. R" c+ ^) }5 E% V- `3 o. Y
<img src="img_nature_wide.jpg" style="width:100%">
8 W$ f% h. i4 }+ d <div class="text">Caption Text</div>- h9 m4 S, ~, Q. _# _6 o' S
</div>' C- s" [, }& u
. f0 n. X$ z: T0 `2 x) d
<div class="mySlides fade">% B( h' S: V, x: f0 M. O
<div class="numbertext">2 / 3</div>( }8 [4 B! u, q, [- ]* B6 n6 ^
<img src="img_snow_wide.jpg" style="width:100%">
C( B/ Z& s5 |1 k. B3 ?, z <div class="text">Caption Two</div>: \9 W) X! ]) N4 u2 ]% i8 \
</div>" ~; @* z; @) M7 M
& _3 w" H- ~' G( R# d
<div class="mySlides fade">
- P( q# T9 z( R3 o% L2 [9 |& S <div class="numbertext">3 / 3</div>% U3 m3 }0 Z* J6 x( C8 }
<img src="img_mountains_wide.jpg" style="width:100%">7 K4 _% k: M" p1 w8 Z
<div class="text">Caption Three</div>- V$ [, a* C" h
</div>, \1 R: ]! G, v0 b( c, X
0 x4 }7 _; a) E: U2 H
<a class="prev">❮</a>
3 f- \% V5 K7 E0 |* T<a class="next">❯</a>
# o9 I. C% \2 g+ }/ s u, N/ O( B) n1 U' ~. p3 `
</div>
: K$ R/ d0 a" ^9 `# i& H<br>
" n% E; v/ o' N1 x6 p3 i" A4 Z' J+ Z+ U, [# l! G3 \/ p4 Y% K
<div style="text-align:center"> B9 j8 L, w* g) P" t
<span class="dot"></span> : a" o1 Z+ P1 T, w/ X0 B0 x
<span class="dot"></span> . e. p& M5 s3 `/ H* b
<span class="dot"></span>
4 W# i. Z5 [" f, X7 X9 r+ [</div>1 N3 D* |, g% ]" E) | h
% p) W; ~: K3 u. @0 k' j# V3 H0 w7 ]<script>+ l% i" I3 x: ]3 H# s9 }8 a) G# u' \, E
var slideIndex = 1;9 w( j: s e. v7 {0 f7 ?1 X
showSlides(slideIndex);: T* i7 L2 U% s3 `3 C3 X7 r' a
4 J+ R# W' U" ]3 j+ Nfunction plusSlides(n) {2 u0 y& W* e" {" j+ g& a
showSlides(slideIndex += n);
1 g( a, @' t/ w1 ], o9 Y, {}# k/ ]# r7 @5 h9 C- N2 C- }" F$ F6 D
8 ^) q) ~/ ?3 K% N; e g4 K
function currentSlide(n) {2 C1 R& C$ j5 L& W) W, F
showSlides(slideIndex = n);
' |0 S+ V) ?( G1 n1 {! Y5 @}
2 }$ R& I) x9 o2 h# [
- \5 w5 d8 c' |function showSlides(n) {4 r: R, H `( S
var i;
; V" W% y$ B# k, E0 I var slides = document.getElementsByClassName("mySlides");5 a' P4 u( ^; Q j4 S) f9 N( r7 l
var dots = document.getElementsByClassName("dot");9 J& i0 c) h, \
if (n > slides.length) {slideIndex = 1}
# d+ @, _. {1 g7 Q if (n < 1) {slideIndex = slides.length}9 J$ | D3 ^; Q2 X0 \
for (i = 0; i < slides.length; i++) {
" r$ L# e, [" _: r/ c0 Y slides.style.display = "none";
: L; ^8 C4 F ]9 E3 } u( K6 @ }
: ~) T$ m! I m U7 K for (i = 0; i < dots.length; i++) {
7 Q8 J2 j# H V. K/ z dots.className = dots.className.replace(" active", "");) R4 @6 `0 j; M1 ~5 ^: U' |& y! ^
}$ Y0 l$ c( N# y8 \
slides[slideIndex-1].style.display = "block"; 1 H0 E! `* o# i) @# A
dots[slideIndex-1].className += " active";0 N! g0 f8 B9 w& T" |5 `# u; f
}
. s. E5 i4 m1 Y0 @6 h; |4 H) v2 M</script>
( V. \9 u' s/ |2 ?+ t+ B6 Z1 |* H2 ^
</body>
) B) C7 `% L+ `9 Q</html> ) Y% Z+ c; L# l3 Y! M. x
|
|