|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 V; Q& ~; P4 U5 G
点击图片方法JS动画效果! d" ]: D% n% l/ E% n
* y) n% Y- E+ }0 g, P[mw_shl_code=html,true]<html lang="en">
2 I) I" b5 ^' w( I; M. ]5 D5 f
4 g4 z! z$ l, o# @0 i<head>
. L- [ `# U5 S7 o1 g <meta charset="UTF-8">! e5 Z1 o" n, a1 W2 T
<meta name="viewport" content="width=device-width, initial-scale=1.0">
) I* M: v% c9 D <meta http-equiv="X-UA-Compatible" content="ie=edge">
$ @' z* Y) z- _ <title>Popup Model</title>/ A2 y6 y+ S$ R6 t, Z" ]
* U6 B1 U' ~5 n8 M+ Z H7 ?
<style>" O$ n1 l, ?4 v& W' X
/* 弹窗背景 */' _" V. N, q: ]0 n [" G' Y
.model {
0 K5 Q: u5 N' o: @ display: none;$ m. x' y% G/ C' x+ l# r9 l# `, E
position: fixed;$ u3 \! ?5 x) A2 K6 v+ h/ r
/* Stay in place */* C5 V* J+ p; _; I7 i5 g
z-index: 1;
% M" u8 H6 e# S# e /* Sit on top */: ?& O) `0 s( a4 u$ g5 p7 `4 F- t. E
padding-top: 100px;
8 w7 t$ r$ Y' X3 Y; e /* Location of the box */8 G/ \$ P- R( v
left: 0;
5 F- o- O8 m) U top: 0;9 y3 e' i( g) O; v, E2 i1 z# Y
width: 100%;
/ T" T8 b% {; J, r n l /* Full width */( ^/ v! a5 R9 v' j+ e- H" `
height: 100%;
$ v& r a: h1 ]# `! N /* Full height */
" k$ w# Y+ e: @4 y' p" N overflow: auto;: E% w& |# ?1 m: Y& r6 l3 ~, x4 k
/* Enable scroll if needed */
, k6 D$ K8 x2 O9 S0 h% z7 r background-color: rgb(0, 0, 0);' r& F' m4 N1 _# _: b- b% ?
/* Fallback color */
& U6 n" O) O* s# x; R background-color: rgba(0, 0, 0, 0.9);' S/ E* I5 @4 _2 C
/* Black w/ opacity */ W) \3 g( l" ]
}
, t8 C: _! N b9 ?
1 L$ \/ I2 l7 R( ?4 T /* 图片 */9 y9 n! W: d- G5 N0 x' c0 D
.modelContent {) o. D! N4 t9 Z& g- b
margin: auto;4 _/ w% v5 x, X. H* w6 D
display: block;
0 V# w2 A( f6 D7 w; g q width: 80%;
1 S. n$ H6 y1 Z, |7 |$ C9 B max-width: 700px;
- x) Q, m% X1 b }5 n( M0 e& o h+ u8 U
/ e" n9 o8 c8 J /* 文本内容 */5 o. }2 `1 I- X
#caption {
2 R/ q$ U4 G$ i: b# N( Z margin: auto;
' L p$ V" R& v& i; u display: block;
& @& L0 m( w# t7 W3 [ O0 } width: 80%;
/ z7 H9 R. k* m* P3 @+ d+ a4 _ max-width: 700px;
2 P& J# V& d* \ text-align: center;
' U' [ A |8 S3 s& D& Z) L color: #ccc;
( n* N. k3 o1 f4 K! h& c: ~ padding: 10px 0;
8 e- {; t b) f% t. d9 S6 O$ V height: 150px;! I1 M) C0 r7 q/ n( |7 P
}
$ {! u' M- q* i) l /* 添加动画 */ a# M; n9 ?4 ?8 \% s/ H
.modelContent, #caption { 7 g. ?/ d; t% X* N8 I
animation-name: zoom;
+ r, W! `" d4 O( K0 _6 x! _& C animation-duration: 0.6s;; d# o# Q+ @. P5 `. C2 h1 [+ ~
-webkit-animation-name: zoom;5 o* q! a% m& Y; b% _' |! h* @
-webkit-animation-duration: 0.6s;; U% j4 o U3 t; Y
}
+ i8 ]1 N r- N6 Q) J0 f
6 s5 H; h& a1 \' e@keyframes zoom {
8 l+ M; j4 ~" W from {-webkit-transform:scale(0)} : w1 z. Y+ p9 d8 v6 }# ^9 p
to {-webkit-transform:scale(1)}
0 N5 ?( y" \1 a}
$ ?6 ~- p E' `9 n' Q
7 E/ p) M2 U) w9 g #myImg {( n0 Q8 s$ U& p" Z/ s/ P h
border-radius: 5px;
. Y7 }" R: u3 L/ A cursor: pointer;: K1 q; |. o5 d% e( L
transition: 0.3s;% ?1 G' H* u2 d( [: C0 L, o; M. a* ]
}: S2 B2 _& g* m2 x9 m: \! R
( K, D5 |3 N( p1 ?+ H
#myImg:hover {7 S- Y9 J5 P. B: {/ H
opacity: 0.7;
& T* j1 q* F0 m2 b }
2 @% W0 ?: Q# r) q8 Z+ n& N! f `2 [* [. _; F; L8 c* i& `! m
/* 关闭按钮 */1 s: {4 V4 u- b/ S: O% m/ v
.close {
0 }0 ?8 ]1 r: g& M8 |6 C% _ position: absolute;
$ K6 b6 ]7 T' _* ^* o top: 15px;
2 C4 Q/ G; Q7 b* U9 I% ~( x right: 35px;$ S' g3 N. Q9 y8 J* }* P: v6 ^
color: #f1f1f1;' J: C @( J) ]8 u3 @% F6 t2 ~3 V
font-size: 40px;
: [" P, d4 l" w( [4 m: ?- W: c font-weight: bold;
0 J' A# l$ c3 V) N& Q transition: 0.3s;
2 V( w, u- Z6 T! ` }
8 J$ G8 o* ?) a( m
) |% T6 y. C9 ?/ A; {0 ]% P .close:hover,
8 `& d. V. r$ f0 f: N .close:focus {
! Q/ F, g! U9 E4 a8 Z8 c } color: #bbb;- |! h, C) U2 k! {
cursor: pointer;
: q m$ k0 p2 Z7 | text-decoration: none;
! M; K& }6 O+ b }
5 Z: u" k# Y6 l' h$ J </style>/ P) f# e8 Z8 Y) Q) `5 S4 N& m3 u
</head>
! [' {9 b5 S$ `$ X. O) b* Z8 ^% T, l/ U: z& a: w) k P9 t/ w1 _, @
<body>, q1 m. G, Z. s& `: l5 d. Z" B9 Q
* ^1 ^' l; a% X3 F' ^( p7 _
<img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">5 B, S4 r7 [' r1 f4 m
" J0 a/ V; B! {/ m1 Y
# f9 L( i% G5 \' H+ t" n" z+ A6 `! M <div id="model" class="model">7 d0 l0 C" L3 s$ ?. z5 T2 |
' h0 [- ^5 i j6 U7 f) I7 ?) W
- T( q/ M( E' F; k6 C0 T
<span class="close">× </span>
3 C5 @7 U8 c& }! L7 _4 |) q1 r. s5 K! t
<img id='img01' class="modelContent">2 |: b. x6 @* s }( e. `
7 ]/ t! C4 P9 L$ x
<div id="caption"></div>
7 y+ C; [( J8 U3 \- u/ g
! k' n% \) e L+ P( s, J5 B. U* E v
</div>
& L k4 X) s4 g6 y2 M6 O6 \# P; @! B
( |3 a% L/ W4 W# C6 [- G+ h: N5 Y1 i
<script>/ j: c+ v) ?7 _; ?' E, p
9 [/ Y. W$ w0 ]! e7 m5 K! G4 Q: z+ S, G
var imgx = document.getElementById('myImg');6 a! N# a% o# p/ X
var modelx = document.getElementById('model');
+ \* @6 z& x& p var modelcontentx = document.getElementById('img01');, S9 v5 d, G( M& \$ p$ H4 u
var captioNX = document.getElementById('caption');0 ?6 Q8 u2 u4 y S5 Q1 n
+ Y2 e/ a/ [( q2 L7 i' \ imgx.onclick = function () {
' U. W- w1 F7 \# ?& _/ U; e4 {" ?: G modelx.style.display = "block";, S2 l& A+ H; [& b9 B
modelcontentx.src = this.src;9 d7 Q n: e* j6 _
captionx.innerHTML = this.alt;6 o* x, y+ M+ Y# N% c( h0 P8 |! o
& c+ ]: K1 o) _6 i+ t }
! P! S v/ @- k$ R- ?% j/ D, S7 Q
. p+ S" {% D/ j9 @& |
8 y/ N& v5 o6 M' f5 g" y# B </script>
# A! S# ?+ I5 U+ G4 A9 j, }! q
1 \4 [/ D0 d: X) Q+ ]% Q+ L/ w+ R
; U" ], I( H V, ] L$ F9 k0 t F: b) {: n" c
4 R9 z+ N5 {# C8 H$ M( c9 A</body>
) j9 S( \8 _% Z6 V4 v
! S/ j) n9 Z; b: u6 v9 j</html>[/mw_shl_code]( g8 W& k- Q" O; P" ~, E
|
|