|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 N2 Y: g. y% f c8 B3 h3 E点击图片方法JS动画效果5 o; @1 y; u& T. m
! x: _4 Q5 Y* u9 u: |- _' L[mw_shl_code=html,true]<html lang="en">
8 _7 W5 O% [) z: x- ^2 R# I3 f5 w4 K
<head>
3 q% J" n! ?+ \! w' y4 y <meta charset="UTF-8">
+ t2 q: E0 V6 y( H/ |" O% O <meta name="viewport" content="width=device-width, initial-scale=1.0">
# q: M" Z8 k$ ?' } <meta http-equiv="X-UA-Compatible" content="ie=edge">
+ d7 ^1 k) h4 H7 b" w8 n <title>Popup Model</title>
. S0 w3 {: U }( L: c
: d1 @% e* v( _: j7 z <style>
( `, y. ~4 u8 @ /* 弹窗背景 */
9 |0 h9 X% |. }) l .model {) I/ z0 _6 j" S; K5 C0 i5 y( {
display: none;
) Q$ u% b, _' |6 X& j position: fixed;
' |5 ]) `0 b) ^9 ~/ c0 g8 c5 b /* Stay in place */
0 U1 n) P1 u* }0 P: H# l& p z-index: 1;* A' n5 i9 L+ S3 K6 s
/* Sit on top */( n4 l$ U2 v- X9 P
padding-top: 100px;
u- [! m6 P9 @1 L2 I1 D3 m /* Location of the box */& w# |4 ?$ {+ P2 C% g
left: 0;
, [" o$ S% b5 p& l0 Z top: 0;8 L* J/ a( i& g# I( X9 A' T
width: 100%;
, e- ?) v/ v& l$ Q9 E /* Full width */
9 ?' y4 c) P2 N5 q5 f5 S( Y height: 100%;
9 U6 T1 I: F7 R+ d /* Full height */- G9 h4 |9 V5 a2 U' P
overflow: auto;% {- w+ Q5 t# q# B
/* Enable scroll if needed */8 `" ]; u# p+ ]5 z* E, u/ k0 `
background-color: rgb(0, 0, 0);
9 z @% u! p p( |: L& g0 M' ]2 G /* Fallback color */
7 H( z0 u$ D U% ]0 b1 s4 j$ M, q background-color: rgba(0, 0, 0, 0.9);
7 a, c- o% V9 J. a- L /* Black w/ opacity */
% \5 l1 M7 N6 g* @5 J }
: Z/ {( m3 Q0 L1 R6 x1 v2 T! k, f9 s0 u( g" T
/* 图片 */) ~8 V: V' |6 d
.modelContent {
' G7 y& w3 w g* _# D margin: auto;* t2 w5 l- [+ e
display: block;7 w" k5 s7 A7 v' n' i2 l
width: 80%;6 [0 X4 t5 T4 B; z( j( p
max-width: 700px;
, E% o7 u( S+ k3 d: o/ l& a }, G6 @* y/ w- s7 V" D
: G4 u4 I7 d" Y /* 文本内容 */
2 A2 c5 P q' d #caption {
/ B5 Z3 n5 I9 N4 M7 q9 u. @, | margin: auto;+ |+ Q, H2 t9 G6 M
display: block;
4 u3 ^# f+ p0 [ ]! E. }8 H1 z7 ? width: 80%;6 H: v2 T4 t" Y+ |( c
max-width: 700px; {( S; R6 q* u$ O0 M5 Q
text-align: center;
5 _: Z* [! W' y9 q% i color: #ccc;
* |7 O: ~& R: R& r9 c3 { padding: 10px 0;1 f2 v' y( }& J9 c. ?9 l
height: 150px;+ y z. `. a. ]$ B* `# S
}4 a0 o2 O6 `" h- n/ J. X6 h1 n5 s
/* 添加动画 */) ], Y1 C( C% p1 D5 F7 W1 C: t
.modelContent, #caption {
' q/ c- t! T; y( E4 Y animation-name: zoom;
" u9 E, E* i' C8 d% B, J animation-duration: 0.6s;
: h2 F( H6 h7 ]2 L -webkit-animation-name: zoom;
( z! y$ R& z. L1 ]: \4 c8 {- B -webkit-animation-duration: 0.6s;
! Y+ [5 N$ r6 _4 n; Z}
/ e" P( B( N2 E* S% x( {2 w
! a& o4 ]8 f: V! R3 m* x5 e@keyframes zoom {
4 C) q( U/ A$ d% v from {-webkit-transform:scale(0)} 6 T, s* [' X) d( z0 _4 S
to {-webkit-transform:scale(1)}1 j. J; _8 C, H5 ]/ y
} [& H% o$ t6 v J- i
. W/ ?5 @) B5 \5 k- s+ l2 V #myImg {
5 Y+ e6 W1 o. C, f0 A border-radius: 5px;( N4 e/ ]+ c7 x" f8 f0 e
cursor: pointer;
' M5 D9 {8 l4 S8 [/ \. m transition: 0.3s;8 x/ `( F: U1 u. j# V! @' K
}" B9 u& U2 d% d
6 q" ?: S0 Z& y9 \8 M #myImg:hover {
: U$ ?: y! {- n+ ]$ I( B1 f& X opacity: 0.7;" H& e. g; A$ H8 A9 r
}' u& D6 S. @0 j5 G( O
- E, X2 Y' [; {5 M /* 关闭按钮 */) d- V* l- x2 B U5 N0 R
.close {
. C0 I( {% ]+ f0 d& G position: absolute;; W( }! P3 u6 `1 Z1 ]0 J8 Z% }
top: 15px;
4 r7 O3 K( R, j" j right: 35px;
- K, l+ S9 g3 @0 ] color: #f1f1f1;
. ?1 l1 B, ~: \ font-size: 40px;$ p/ ~9 M8 ? @: Y1 b( y: z6 P
font-weight: bold; s7 F: Y& f* _/ `6 w3 f9 s, d3 _& n
transition: 0.3s;1 M: q' }- m* Y5 h! Q
}& |. n( j1 R8 [ _# `( Q; `
$ O+ x0 _5 ]# h2 T .close:hover,
7 p0 R( ]8 q4 M .close:focus {
9 C+ v" `1 Q6 Y& e( H# n color: #bbb;; B) N$ E8 M& z( U! `8 Z
cursor: pointer;* v9 A6 v! Z" g5 G% c6 ^) Z/ W
text-decoration: none;
5 b- q8 M+ ^9 G) _2 N Y& u3 c8 | }# ?4 R( o3 C8 G4 v3 S' S ]* x
</style>
0 ^9 e/ T6 ^( ~, G$ c1 Z. c2 [</head>
# t* }8 m1 L8 `/ U8 L) J
0 J+ E/ E ]5 r<body>
; l( c& x4 a/ o# D4 }+ `5 B' F( p
( N, A" P, T6 N/ I- c$ o <img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">
5 t) ~2 S+ {- X; m6 W; v: w% L# E+ n
1 `% W9 y0 Z( ^( _* T
( E$ [/ h1 j: D, Z+ X/ y <div id="model" class="model">3 V6 c" @/ L& D/ }4 `" F5 d
\2 O1 @( k( G9 s z, [/ n
) M+ R( w" K$ }: L6 a2 D$ W <span class="close">× </span>, S4 v! ^6 V- S* m# b* g
5 g- n5 D! H" A, t: B3 D
<img id='img01' class="modelContent">
: K( u. h0 r0 V4 D9 B" P: f7 \6 I$ s \0 q
<div id="caption"></div>
! n. M. r+ k* E Z9 ~! t+ h5 j+ c4 O0 {' f O# X
! I, o! e. O( s5 K$ f* N+ U: f8 n </div>- p" ~# n! _' Q S V
4 ]) U4 }. z G0 k# p
+ E, Y: e8 p5 p; c6 P2 L, F, k
3 Y4 K/ o2 |7 Z& i5 P) W2 t
<script>* x2 i: w2 V5 \: [
1 {, U, ]7 p; `# Y' y# B
var imgx = document.getElementById('myImg');0 m/ \) E# T9 E! B) P8 g6 X. G
var modelx = document.getElementById('model');6 X( M5 x/ E( ~+ y
var modelcontentx = document.getElementById('img01');
: \8 m& R) M$ i8 K. A var captioNX = document.getElementById('caption');
4 E7 S; x. ]$ S4 u: w2 h; |+ w. r1 O8 D( J9 g
imgx.onclick = function () {4 W0 Z' H6 ]8 p* y) y5 D/ N4 @
modelx.style.display = "block";
f" L6 ~- E9 g( p" t4 u modelcontentx.src = this.src;
* s8 G( x$ \7 o$ E: t captionx.innerHTML = this.alt;
( z7 A. @' s5 M1 {# c" t4 y% j7 M! C& Q' m4 T9 h2 q
}* m% v* G- G* D+ ~( H
. y8 s3 f2 o C4 L8 E
0 F8 v9 z8 w+ p# {( m1 U( v8 I9 U </script>: P- P! y$ Z$ L# I9 B) o
# _# x, Y6 g' I' K! G z! q" x
" ^1 B7 D/ Q% X6 K
; x# ~; I+ k e5 J- y. C) e0 o: Z( b+ _; d/ y* N5 A1 V x
</body>
1 w* I" E$ j: C5 s/ d+ q
( X+ N/ h: W1 B; _; V</html>[/mw_shl_code]
% y: A s! n" |5 ]/ O, I |
|