|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! _6 P3 n/ b7 h/ ?4 S$ ]9 s$ z
点击图片方法JS动画效果7 ?3 B, y: C6 \" q0 ?- p8 U
5 z/ K" ] `9 s
[mw_shl_code=html,true]<html lang="en">
( I5 s& Y4 |" J' k7 h: W! n' D# Z* j3 T
<head>
2 _9 l# K% n, J$ O <meta charset="UTF-8">* O/ E1 B2 }( S3 I1 I% ]* T% j
<meta name="viewport" content="width=device-width, initial-scale=1.0">
' S( g; }4 i: c( f0 k" b <meta http-equiv="X-UA-Compatible" content="ie=edge">
6 T. K4 K. u$ q1 [! [ <title>Popup Model</title># ^; W) ]9 Q, a5 g/ @+ A' l& r
9 @# @0 m. K. N/ u+ v* K0 Y7 O7 |) G
<style>
o7 D& E: M# V& Y: j( U /* 弹窗背景 */
. e. O# R! ]! |) q P) e6 X! y9 s( u .model {
. F+ ~1 l, @' S4 R+ M% a: c display: none;) N( e. L- F: m9 E
position: fixed;
- }" `9 j7 U( @" T+ h1 B /* Stay in place */
( ^, e" D" y1 L3 y5 S; X, u z-index: 1;. K2 v, l @5 E: P& f+ ~4 J
/* Sit on top */
% D9 v _# y. D3 `- Y padding-top: 100px; |; h& ]! c9 M* c
/* Location of the box */9 {+ \8 A4 I7 \% r8 ~
left: 0;' \8 H: z4 K- X& d( m
top: 0;9 w/ B, x9 o/ u) h! v8 P- \
width: 100%;
. e6 `/ a1 ?- Y( h' S) v /* Full width */
, @5 w( I8 \3 z a7 B7 B height: 100%;3 I `! D H- O% `
/* Full height */
2 q: @9 a- v) ^' A9 {3 H overflow: auto;
" d/ @7 p; N, C; m* d /* Enable scroll if needed */7 D6 O2 L" U; U* m2 \0 H) F
background-color: rgb(0, 0, 0);
. C1 G p/ c: ~' m7 _# O4 W H /* Fallback color */
% J6 \7 `4 {0 c. k background-color: rgba(0, 0, 0, 0.9);0 t: V7 y D9 U/ L- k! | E
/* Black w/ opacity */
1 t8 G/ j# e+ k) @2 Z } d1 `( [$ A6 U- o" q0 J- Y
' M5 t" q. R* }/ U) a( w9 } /* 图片 */. b, G; i/ s# m3 Z; Q# h' S! l
.modelContent {2 ~6 |: w$ i) m1 J4 B7 i
margin: auto;
! E( |+ E2 D" `# O display: block;" M' s( t1 C8 t7 o4 G$ z% J
width: 80%;
2 \7 w I! P1 t) } max-width: 700px;% x" M" R w7 W: l! s) p( y) v" ]2 w
}! V Y; X" h3 e* F8 V
& k4 M6 ^$ ]; V! [
/* 文本内容 */
$ ]4 B& ]1 O0 E) e #caption {- }& j3 ~& W' H7 h6 f
margin: auto;: W* k$ }0 `# K; N& R0 ]) s5 u
display: block;
% K: P1 y& e5 L9 j! Q5 {& g6 P" E width: 80%;4 i2 ^* B2 k9 b. I& p
max-width: 700px;
: F/ }! f( T5 ] text-align: center;, h: J9 [8 T0 _9 Q8 ]0 o' K. m( Z
color: #ccc;6 ?8 V1 _. f; x2 K; t9 @- b: \- A7 l
padding: 10px 0;
- d( j+ M/ f9 [5 D% r height: 150px;2 i R& s9 \. r
}
- P. _, S$ v6 f" f" r /* 添加动画 */
- S+ G8 v8 O: F3 H+ B.modelContent, #caption {
) s! x" i; J1 i% s% O* D animation-name: zoom;
; k `. U+ f, Q: I animation-duration: 0.6s;/ ^: H. s0 e% H0 b {/ e& I
-webkit-animation-name: zoom;
$ U; d# P, y: D- _9 c N! D -webkit-animation-duration: 0.6s;' X9 g4 s4 s# H6 N" \, X
}% J* E, e. }: ~5 F1 c: D5 u
( B C7 M {: S+ a: ^' |$ V
@keyframes zoom {/ g6 J3 j5 S+ h
from {-webkit-transform:scale(0)} $ f$ s- b1 W g; g+ S9 N! V# u
to {-webkit-transform:scale(1)}
H* d$ N% |* n) N}
1 T* I& o+ J, Z$ K9 Q7 C4 t5 d8 m2 U8 Q
#myImg {
4 Q0 `. H, d( C% b, ? border-radius: 5px;
& g! b( w) x! h3 Q% n cursor: pointer;8 A- q4 ~1 }! d0 [' \
transition: 0.3s;
3 Q4 r. b& v/ T( c( J }$ n$ e! I4 \) I- T- t
2 [, S. ]/ p5 w' ?- { #myImg:hover {( |, {* |* u! W7 e; p
opacity: 0.7;
- F4 ?( b: E. [ }
% I# `' M: s/ ?/ U* J& Z. a( g- f0 H ]5 Y! ]
/* 关闭按钮 *// R3 g/ p8 j6 I/ n3 p) D
.close {) ^7 l% w" n( Y3 H
position: absolute;+ }& B5 V2 i- }4 B6 K
top: 15px;% o3 \ Q4 v1 W: [% F
right: 35px;0 b. _- l1 t& T. S5 A3 H- R- d
color: #f1f1f1;
# d* l0 j3 b+ G3 s& j7 J font-size: 40px;8 f6 W8 s/ @2 H' t" O
font-weight: bold;
( Y- H4 v3 e9 W0 i2 C% w5 Y6 F transition: 0.3s;
' j9 ]2 M: h5 Q }$ Y6 }* f# e) ]" w$ u, B
6 t8 p3 F9 ~; a+ U" E, u5 I
.close:hover,7 {6 r+ W/ F2 [- I
.close:focus {
- B4 I, W( G7 D Q: Q9 e! x, Y color: #bbb;
( D/ U6 Y! A( q cursor: pointer;' T& }8 f4 V$ {, {
text-decoration: none;1 v2 F7 k _: o
}. W0 R+ d6 b8 e6 G$ [9 w3 t {: S
</style>4 x1 o, P/ Z. |) j; X
</head>1 f# M& v# t5 Z+ n2 J
9 @+ N" Z5 q( ~' [9 H
<body>/ w2 Y8 U( [7 `: e
; ]* P$ C3 }7 ?, o/ X9 V! ? <img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">
T( u- O$ [* K( \, U, C3 q& f9 p! a! I, P7 j
6 K+ y' M: t O& M <div id="model" class="model">% K( K4 r! V c3 r
2 K# t8 _; q. s5 Z6 q4 B N6 j
) M E* Q$ e/ t3 V! R <span class="close">× </span>
+ J: i4 N+ M$ d! Q3 _% f4 s8 _; w- u$ W& E2 m- [3 a
<img id='img01' class="modelContent">2 d8 q' O! h# m" n0 a- H0 V
- `' o8 d. X# Y8 j/ w' r! k- f <div id="caption"></div>
& C* E+ r1 P! X1 e4 B3 r
0 D; g, m% v* v4 d* C& \' ~2 `0 Y6 q* G0 W W, |' ^1 [8 n$ \
</div>9 L( J+ _9 R* \ V7 y' u
5 E/ F4 D& W2 {5 \4 u2 a# v# I: A
+ V9 B, ^1 t% A3 ^# h1 x$ z
1 D+ c; ?5 w1 u# k
<script>
/ p' I* q9 u& @
! G5 b. \/ C% f' R+ ^7 z& E var imgx = document.getElementById('myImg');! h: W7 G, f) I: h/ D
var modelx = document.getElementById('model');
9 ]/ {) W- I' L$ n var modelcontentx = document.getElementById('img01');8 P) t; n& i7 P; ]2 g# D) q/ u
var captioNX = document.getElementById('caption');* b4 g+ e9 i# {
. W1 Z: D6 g2 J% | imgx.onclick = function () {
S; h( i; r3 T k! M. L modelx.style.display = "block";
4 n( u. x/ `& h0 f% G modelcontentx.src = this.src; u- l6 {, h" G
captionx.innerHTML = this.alt;& Y- [: {# G/ x6 L$ y% k# m
5 T f. B; L& P* N! X: N- i/ e# @ }7 [4 e- k* n9 b# t
, O) k4 @# H8 h$ O# A4 y! T- p+ p, G6 R
</script>3 S$ g+ q% D: A
+ R' e, E) z- F9 Z/ h1 z
9 N- W% n2 z& p# V# O+ B6 V0 F7 A; L2 _ A0 J2 R' C6 W
; x$ p( W' E, B+ C, C4 j</body>! a7 D- p: _8 d, F2 C3 l5 V
' Q$ @: M2 _3 h" D
</html>[/mw_shl_code]; f- P" V1 I# |+ S! W2 C
|
|