|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
) w5 U3 v- ^8 e( I) d5 R- j
点击图片方法JS动画效果4 [) S% c0 W8 z' t3 n
* @/ _( R! N( i+ l
[mw_shl_code=html,true]<html lang="en">5 P7 z" w3 h8 O7 U. Z
) `( \. M7 F3 ?* ]' |<head>
G# L* v$ R9 m+ _ <meta charset="UTF-8">
4 f+ V/ p# I, \& z <meta name="viewport" content="width=device-width, initial-scale=1.0">
) o# W. V$ U8 D/ Y* k' P0 A <meta http-equiv="X-UA-Compatible" content="ie=edge">
# k* i# J5 H. ]6 U( \- Y+ B2 T <title>Popup Model</title>
( o- U {# q% v& w( Y9 d+ n9 `) o2 z1 l( W# }, ^# h9 C
<style>7 n; b# o2 n& c: ?! L
/* 弹窗背景 */- q- n7 w0 u# N2 M( [& K6 G
.model {3 q0 K5 a2 g) E
display: none;
- o1 {6 c* r* E5 n5 U7 T position: fixed;% e! |$ w5 ]$ _/ }# _0 y
/* Stay in place */
% d) L s. G5 X4 I+ @3 q z-index: 1;( |) o6 R6 k3 t9 G
/* Sit on top */9 G U8 P; s# p; v( e7 `- R
padding-top: 100px;
6 L/ H0 x2 f/ P! I' f' D8 k /* Location of the box */2 Z, C+ v9 K6 w! Y% R! K0 P! \9 d8 L
left: 0;& q K( G( \( M" t2 ?4 m& T z2 \
top: 0;# M6 M8 u# H5 _5 L
width: 100%;
' \" J( z. ?$ a /* Full width */& q/ B2 T; N7 g
height: 100%;' T" F0 s7 x9 `; j- c
/* Full height */
) b2 }7 c+ e3 m3 r: M0 m overflow: auto;
' `' ]' T4 A- l- f: j0 j2 S /* Enable scroll if needed */; K" D p3 v- Y! S( q# X/ V
background-color: rgb(0, 0, 0);' @& p# R5 S* A, z$ h# p5 V
/* Fallback color */" s% f* ^& z+ q& {7 P1 u+ S
background-color: rgba(0, 0, 0, 0.9);
0 j, F7 K- P. X) [0 N /* Black w/ opacity */% r: ]) d [# Y% S. Y$ Z: X3 V. u
}
, j5 ^; v, @% V8 g! K) l7 T1 a8 P) n% X5 T
/* 图片 */; T+ y1 ? P% g( O
.modelContent {
3 }, \2 c) s5 X+ a" s' Z) D margin: auto;. S( t( n, Z/ s) {7 @: f- J4 R
display: block;9 C7 L* j( n! ]6 {& M* X) z" K
width: 80%;
& Q9 I$ `' L5 [( q* a# ^- Y max-width: 700px;! q0 v% T' T) _" I) K0 Y
}
: K5 e0 F; L/ J
; l( W* H3 M f! X /* 文本内容 */
% N( v2 j% m- f+ U8 y0 J #caption {! a* ^$ ?& h* P, r6 k
margin: auto;
3 V/ e$ Q4 n5 c: J display: block;
3 C F' b0 D0 h8 J' N4 m, C width: 80%;
9 w9 Y& E* |) `* Y3 j2 z% h+ v max-width: 700px;
$ T$ k. X/ Q: t( ]' U7 M7 q( ` text-align: center;
|& w4 F2 B; B* ?3 p1 j color: #ccc;
0 I9 a5 X2 m2 `4 N- R padding: 10px 0;5 Z( f- v/ W) x4 |5 h3 H* P$ i
height: 150px;
' d6 r+ X2 Q; B! m- C+ ~6 s }
/ y5 _/ L! _# B) t9 Y; P% D /* 添加动画 */; n9 C6 q B$ ~7 Y9 _4 C* X
.modelContent, #caption {
7 R3 [" h% x2 r$ C2 u animation-name: zoom;: \+ N/ L' I+ V' J# p
animation-duration: 0.6s;
3 C+ }4 e5 I' p* U, @+ j -webkit-animation-name: zoom;5 r" A% t; U1 Z! p6 J' t
-webkit-animation-duration: 0.6s;
! @* s. v+ m5 p3 a3 @}
0 l; I8 r* S8 \: H# U7 e, j6 L! a' B
@keyframes zoom {
3 R9 t! V1 G& i' R7 d; `* ] from {-webkit-transform:scale(0)}
# B- r D. ?7 [$ S2 ^4 K to {-webkit-transform:scale(1)}7 X& {! ?+ `+ }) U4 B/ e
}
, _9 Y* J' r9 s# C3 d T: N; [# G
+ w7 n* Z7 M j/ E6 o #myImg {3 P- I: N! O) q+ F& q8 B) [
border-radius: 5px;* L/ |; j- {" v! G) A9 ^; M2 [
cursor: pointer;0 a6 B$ L' Y3 R6 [* c. M* ^
transition: 0.3s;
* S. Z, s7 B$ j# F/ L. [5 l2 H }' e, `9 ^$ Z/ w, f4 b9 A
6 { b- b) X8 t0 G/ C( A/ N9 n7 D# [7 R #myImg:hover {, [ C. W' t2 ]6 B6 s
opacity: 0.7;
* k9 ~ l5 q+ L1 v. {! F }: G1 s2 g7 P P1 K" ?- Q9 w
& H/ F7 t8 {6 l7 j. D: ~ H
/* 关闭按钮 */, m$ [: G% g# m
.close {% l* k9 r! i6 W, `! ?
position: absolute;/ `! n/ J0 V" K6 O" e% Y o
top: 15px;- i) F# B U/ C" f& t a, W
right: 35px;; L% b1 C/ `3 J: S8 F
color: #f1f1f1;
1 u( a; c; b+ o font-size: 40px;
/ i" f. G, l1 c" ? font-weight: bold;% S( r/ c1 r m& Y7 ]
transition: 0.3s;
- m: x, L O" f$ A9 W3 e }
2 ^5 i- o: K) ~ t4 b7 J6 d7 J1 Z: L' c
.close:hover," o/ V( ]2 d4 w8 \
.close:focus {0 R& h7 j! Y* j; z# d) d
color: #bbb;/ g# _# G8 r5 ~ t; G
cursor: pointer;
; c4 E) V: u" E8 L text-decoration: none;
% L0 J6 Z3 h( l5 B- H' k4 D. w }
6 @7 E" V1 j' D& Z. n </style>
1 Z- e3 ~0 i F5 q</head>; _' E4 Q# Q0 ]# o) Y" c
9 ]+ n" u$ F* i<body>
8 r0 o. b' ]: h5 i
0 ~ P) G( o; }) y& Z5 Q9 v8 O <img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">5 B. S4 B8 P) P/ \ M
/ V s- `) r' ~0 v
& w* b) F3 [4 _! @* E* F <div id="model" class="model">
2 z8 {/ J# e% W! L) x, y# B
: b$ ^" w9 K! R/ ]7 M0 c, P( e8 F7 z. ]6 @
<span class="close">× </span>4 H# n% ?/ P) A: ?# c0 m, a! o
% k* t. P" F1 e; @' O! l* y! W
<img id='img01' class="modelContent">
5 i- R' h' v, V4 F& \
5 s* W3 i$ F+ E9 j7 m p4 S <div id="caption"></div>* K4 @' G/ L9 H% w" R: l9 o; ?
% K1 ]8 B5 |' W! D. t1 G8 z
, i2 W' D# l! F% e; H </div>
# K5 g6 z8 u4 {/ j" ^# v
: g& Q/ b; h( m) R# @! I
8 L. p( T) g7 C# E
- o+ q: ^( L' c$ O+ Q8 U# E( H9 [/ O <script>
7 L) m1 y/ P: ]2 H# o
4 k* c/ H! L0 v6 J' B, Z) O var imgx = document.getElementById('myImg');
/ R8 c4 a7 r* h var modelx = document.getElementById('model');7 [/ B9 P- T# d" R$ K) {/ [
var modelcontentx = document.getElementById('img01');1 K; H% h! E0 C5 o5 i
var captioNX = document.getElementById('caption');% [# [) I9 O4 n3 G8 r
+ w% |8 x6 m" D% ~ imgx.onclick = function () {
$ H7 M% x2 {6 E2 L- u4 o modelx.style.display = "block";0 M5 j" P: n. q! g/ ]/ ], N
modelcontentx.src = this.src;
o% E* w$ n& d3 P9 L1 s5 j( c captionx.innerHTML = this.alt;' R' L3 ?" Y8 ]- P$ i0 u
: a) g3 [# W( l9 M
}
5 |% }" Y7 E5 L) t' V$ e
. N1 Q# W e) x# W$ k9 B5 O. O
; q; ^- \+ \3 t0 i( P+ q/ _' ^2 v </script>
/ j# Q8 T- I+ D. C' S
! H" K9 ?# \) J* |' N. @$ b2 \
" Q( \4 Q) u8 @
* Y+ U3 V: L; i8 _) C0 c+ `* L
; x4 b$ D& X8 W" n# m: g2 C: K5 M</body>1 \5 K3 r& h: N! z6 B
& b% c/ @& G3 @) O</html>[/mw_shl_code]
3 x, g! B, [' }- P3 F) W |
|