PLM之家PLMHome-工业软件践行者

[前端框架] 点击图片方法JS动画效果

[复制链接]

2019-11-7 16:55:28 2052 0

admin 发表于 2019-11-7 16:55:28 |阅读模式

admin 楼主

2019-11-7 16:55:28

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x

& z7 f8 @8 a6 o6 @9 L5 o点击图片方法JS动画效果
# r, x: k) j8 {3 d9 T1 j9 V3 X0 Q! A
[mw_shl_code=html,true]<html lang="en">
& L5 A* h3 h* P- t% v$ h$ ~/ [8 {- H* i8 _/ j& a! h! Y
<head>* ~4 x1 [( W9 U: ?+ Y* P
    <meta charset="UTF-8"># m9 J8 R/ O2 m0 I
    <meta name="viewport" content="width=device-width, initial-scale=1.0">$ Q+ n. m0 O2 j) b) C, c
    <meta http-equiv="X-UA-Compatible" content="ie=edge">% o' p: o  z* f5 L4 ]! S
    <title>Popup Model</title>. M4 P) }4 M0 V2 N3 h! J
( P  c3 G+ [! \( f5 K! J+ N
    <style>
$ c2 e0 K) W/ ]1 @        /* 弹窗背景 */& z8 C# F! \5 B1 b$ `, E5 Y
        .model {
# e0 z1 t: V* L: W& A" M            display: none;
  ?+ p- v, k! V8 l' J/ m            position: fixed;1 L9 v7 p3 U3 I& k: P6 \
            /* Stay in place */
% q" P* G7 L+ W7 i% |# O/ X6 l            z-index: 1;! U5 I; l/ C1 p* H
            /* Sit on top */, V" Z8 H, |6 J( W7 C
            padding-top: 100px;
# Z9 l4 f, N. N9 m3 U            /* Location of the box */' G1 |5 \* X4 ], |6 c" Y
            left: 0;. \( l: [. w6 ?! S+ V" I. c
            top: 0;
! u* E' w" h1 N            width: 100%;
0 n4 M2 D1 G. R            /* Full width */
, Y8 L7 w0 C$ B            height: 100%;
/ P# p6 B) h" p- Y" E+ S% Z            /* Full height */
+ ^1 C5 @% \  I& p4 J. e1 ?8 ?            overflow: auto;4 c- `* l& L- y% R: h0 n
            /* Enable scroll if needed */, w5 W2 A. ?" w9 J
            background-color: rgb(0, 0, 0);& R! |& G$ f. r6 b' A& E
            /* Fallback color */
# g( M' w9 l' ]3 M+ C% p* S0 l3 Y: X            background-color: rgba(0, 0, 0, 0.9);
0 P$ q' E) J8 s& o9 E            /* Black w/ opacity */
0 I$ X" L; n6 Z8 I7 G4 J* N3 u        }
4 l, L: l: A! w
4 E- J" C; f% \        /* 图片 */
& Z( ~+ _- ?& \        .modelContent {; z: s! t" V6 S$ j; h; Q
            margin: auto;' o+ a6 B9 y0 Q4 V% k2 D5 l) ?+ v
            display: block;1 K7 X  q  m" ~1 g$ U( a/ j2 @
            width: 80%;0 }. @( k2 J2 ]( g/ V
            max-width: 700px;
# p% |- y$ n/ ?$ p3 Z        }
) R& a7 C$ |  G4 |& o7 u
+ f* N9 P+ S, ]" v        /* 文本内容 */
" g  [$ N' c% S# m* x2 ~4 ?8 x' M  a        #caption {
* P% X8 J# v8 ^            margin: auto;# X9 d& a5 A! i' O7 q% s/ K5 _
            display: block;6 x. r4 r: `8 ]# P$ I( L" Z
            width: 80%;/ O. l  u8 ^( T; D4 E! K5 x6 t4 D; A
            max-width: 700px;
: K- w# f) |* G) C7 B! C5 U            text-align: center;
/ ?, h3 _! S: ~& _' c3 R- z            color: #ccc;8 \7 W( f* r9 c7 g
            padding: 10px 0;
( L+ g/ R6 `6 h0 R% ^            height: 150px;* ?: m* b) K3 J1 }
        }
9 p( H  G. e3 ^7 j) C7 @+ ^9 }: N9 P       /* 添加动画 */6 w/ W4 Q( b3 a# T3 O
.modelContent, #caption {  
# y; @% f4 D2 X8 F4 e    animation-name: zoom;6 W4 j( S2 M2 P3 p2 M- h
    animation-duration: 0.6s;
* l" [) Q- m+ ]# ^. Z/ A# I    -webkit-animation-name: zoom;
. H1 u- X: E' S2 _. I/ s' E    -webkit-animation-duration: 0.6s;( K7 x) z; m' r# I& n$ x, n
}5 \9 W( Z. |0 I: ^# ^2 t

0 F% V, S1 |7 [@keyframes zoom {8 r( Q( A  \" a, M& u
    from {-webkit-transform:scale(0)} 9 q" ~2 v4 u9 y+ w: |
    to {-webkit-transform:scale(1)}
; {4 p5 d5 p/ E6 l5 K}
8 Z% g) o4 Y* ~1 @' g/ a5 y* c2 p- C3 P2 t! D% @8 @0 c# A* n! R2 ^  k, L
        #myImg {5 ]# g6 o3 ~( `9 l; Y
            border-radius: 5px;! A. l( Q7 H$ }* ^! }
            cursor: pointer;
4 X5 `. F) t  |; B7 D, W" c7 _            transition: 0.3s;5 L  Z4 g1 f9 L0 F
        }. \) x8 V: P) i" c# Z
- |- K0 Q1 J7 Z0 a; [9 i2 s
        #myImg:hover {
; Q; N) F0 y3 A4 |  @8 r/ I            opacity: 0.7;7 Z& ?8 W# \8 o! a- _3 \* ^% e
        }' C5 L! u; j/ ?$ X
0 |+ w& k+ a# }! g6 y( F6 g
        /* 关闭按钮 */
# [- S' p7 ^7 l1 j* x0 z4 {- n        .close {* a. |; s  i9 B' ~
            position: absolute;) f5 @: R- t9 b+ V$ A' u1 D0 b# e
            top: 15px;* n5 N# A1 D) C2 w/ p2 H
            right: 35px;/ m4 e3 D8 F: r  Y1 f
            color: #f1f1f1;# D) Q, x7 A% M" p. ~* q! u0 m
            font-size: 40px;& H6 h! Z5 f& @  R
            font-weight: bold;* h4 d" r. ^. p$ V9 \$ L6 l. ^
            transition: 0.3s;' F# P/ U: p' x
        }$ v2 V9 o7 R2 S$ k, C; G

) S* `& r. T/ A9 P7 \4 N5 y, g  x        .close:hover,
) v  O- U; |0 C: d1 I        .close:focus {
$ L# \: D3 a0 |5 K. C: A            color: #bbb;$ g& K$ o$ ^  `
            cursor: pointer;- M* |7 d# A1 r) T
            text-decoration: none;
& |3 [: Z7 m) f; I4 K        }
  R2 I( M' T. N: U) l    </style>
( m4 I* U2 S8 M/ i$ e6 ^) f# J</head>! \% c4 Z( s( r0 L6 t
/ y$ G2 q! P1 f, g
<body>
* ?9 g( G, i+ {+ `8 q
4 s; v; w- @& a4 ]" ^0 K    <img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">
( w6 G) j5 f/ C9 N* i. ^. w0 s6 v0 s2 N) o5 z

' ~) @. Z7 I* Y! W0 y    <div id="model" class="model">
4 J! n- h9 G9 d
3 `7 \" _+ `0 x8 l% ?' L
; x$ d4 ^- w% D+ T: `- C        <span class="close">× </span>
/ \9 x/ P8 p* ]7 S4 x; j  F; |
  @' K7 K  O  h) ^1 C        <img id='img01' class="modelContent">
2 A) o4 {+ S! A9 A6 l" E) j8 }( E* B* B$ M5 [
        <div id="caption"></div>
+ i7 v; s6 J$ }( p, `9 f6 F+ U( v
. g" X0 S: [2 k( W- S
    </div>& r5 W& L- }( f9 N7 ^% ?- Q

2 U, x! o/ M7 s8 w. n# g% S& v  K% U+ p4 z: o8 ]6 q0 d. S' m

1 V- l3 k- B% Z0 l+ N    <script>2 R! f8 K0 R" D3 G- G1 g
2 a4 E! ?4 Q; B. R  j: }; |& T9 b
        var imgx = document.getElementById('myImg');5 D) ^( ]" ]- R6 ^: t; P2 s
        var modelx = document.getElementById('model');
: S1 s& {& t  `& `        var modelcontentx = document.getElementById('img01');
4 |5 R3 F5 [3 q* c( l        var captioNX = document.getElementById('caption');
$ g: C- r- p8 s
: W3 p; f2 d# b& m        imgx.onclick = function () {
. U1 i# ~" q2 _4 S3 g. M4 g            modelx.style.display = "block";5 ?2 M  s) U! D4 Y& Q
            modelcontentx.src = this.src;5 Y6 e& |! p$ V4 c
            captionx.innerHTML = this.alt;
+ A9 E1 L4 p* s8 R  X6 M# t% R% d' u; T" ?
        }
1 b. {7 b5 T( w$ M; Q8 ~" k, J# A8 }& m/ u
. P$ ?: X( z$ D0 j- f$ q( j
    </script>
+ c$ c; {, T% i9 G- q1 N0 q
8 a% N, Z9 z+ |6 o# E% b1 @" \' T" O$ j# Y" R! _8 `

( j- V( O9 p# ]# A6 s0 M0 v0 n* q- a4 W! N; A
</body>
  [2 E# \8 w/ G! G& W7 T
$ {# G+ }; a) o  e" |/ U: ~</html>[/mw_shl_code]8 L, X6 y1 ~# O: j5 H2 `" ]# Z
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了