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

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

[复制链接]

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

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

admin 楼主

2019-11-7 16:55:28

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

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

x
. q- Y9 s& d4 ]8 z9 H. P7 r6 L
点击图片方法JS动画效果
9 g/ k9 `/ X; o, |2 W
6 I2 P6 l: j6 \8 j+ H[mw_shl_code=html,true]<html lang="en">( C* T' r8 v  [9 h
- z$ N4 t2 m* P$ b1 p
<head>
& l8 T# D# }) w    <meta charset="UTF-8">
- M1 E% y. d9 P1 ^' J5 t    <meta name="viewport" content="width=device-width, initial-scale=1.0"># y* Z/ E( V$ N& F
    <meta http-equiv="X-UA-Compatible" content="ie=edge">/ Z$ _3 L+ c! y" l; l
    <title>Popup Model</title>
3 d+ a1 w& c0 T% }5 ]) n- c8 b
    <style>
5 h7 Y3 ]+ N/ A) E; k  e        /* 弹窗背景 */' e* \" Y! `* |5 b
        .model {# }$ I+ \7 ^/ ^) i7 ]/ k5 @
            display: none;0 Q, j$ y0 F/ c* ~. x: P- H
            position: fixed;! W% c) e' x3 p5 ?: U, M. P
            /* Stay in place */
3 F) U- i8 e) R; M% M3 I            z-index: 1;
, G! \: z# V, ], o4 N2 z& {( |4 ^5 `            /* Sit on top */( g( ~7 M2 u% `$ `* p0 d
            padding-top: 100px;
" B3 j* ]  A( K) n( v4 }: P+ B            /* Location of the box */
4 f8 c7 R& A( h3 a! G/ |9 j/ f& e            left: 0;$ X5 z& M3 K3 D$ a0 G1 \
            top: 0;# {$ I: f: n* c9 K( I$ w7 S" ^; @
            width: 100%;7 y6 H% K; `/ c
            /* Full width */: b' N' O. i4 P0 @( X6 v
            height: 100%;2 C9 t- D- P$ x7 m1 L
            /* Full height */) i0 |: h/ c  U) H
            overflow: auto;& e, r2 S3 X) C2 n3 g7 O% U5 _6 N. V
            /* Enable scroll if needed */8 Z( i: x% v& v% B7 I
            background-color: rgb(0, 0, 0);) R  p; }1 D3 X1 E
            /* Fallback color */0 y* Q: w0 ^. p2 a3 N
            background-color: rgba(0, 0, 0, 0.9);. j. w# T; C2 D4 T( L$ _
            /* Black w/ opacity */& K& f  w3 T" ?/ Y( X
        }
) ?: u" i  H3 m# p
3 v3 a: G5 s) h0 T        /* 图片 */
' c* j7 L1 I0 w        .modelContent {
5 T# k7 ~# Y& m            margin: auto;
" k0 R: m$ _# M. L  s            display: block;& k( _! E9 ^) `' Y; x
            width: 80%;9 h5 ~/ n! J; r" s9 E
            max-width: 700px;
7 t/ L+ y3 I2 t        }
( C9 U5 E' ]& ?, @! w$ K9 w% E. s& p6 @2 Y/ v  Q
        /* 文本内容 */1 M: o4 E  Y1 Y* o. ~# k2 k
        #caption {
' L# y/ g- P$ K% [+ X& Q            margin: auto;1 R% r/ c9 d- Q' f; c/ V" p
            display: block;$ s. E# M9 D& R/ V' k
            width: 80%;7 [! |& A+ m' n4 W8 Q: x3 f
            max-width: 700px;
; w/ S" A& S1 w9 u            text-align: center;
3 b  A+ F- z0 a3 O            color: #ccc;( O3 F) i) O$ Z, A* `- R% G3 ^2 O, W
            padding: 10px 0;4 c  T( k: q1 e$ S' Q4 @8 C
            height: 150px;
) `% X5 h% R5 _' B        }
1 n3 W$ s+ C) H4 E2 W       /* 添加动画 */
- U4 V/ c1 C2 E: y) T.modelContent, #caption {  4 s7 g+ F, B$ @0 H
    animation-name: zoom;+ t2 m6 r! Z( M: `8 t. L" j  S
    animation-duration: 0.6s;
6 K$ a8 D$ `1 ^7 r    -webkit-animation-name: zoom;' n/ d* b! _# _7 a0 j
    -webkit-animation-duration: 0.6s;8 E9 K4 @3 i6 H- m4 Q# s
}% i, [6 F- g+ [  l: X5 ^7 ]
7 R7 U7 k8 x0 L6 A- Q% t
@keyframes zoom {
6 H% K- \7 o5 {/ u    from {-webkit-transform:scale(0)}
2 K! S! ~; v4 P$ S; z    to {-webkit-transform:scale(1)}9 S& L4 s2 }" W/ }
}
* S7 E  e% x+ b. @3 L& F& s" y
! z. F2 p0 j' E+ {$ O8 V4 I' x/ W+ O        #myImg {& r5 X4 t3 f1 U  B  F
            border-radius: 5px;+ {' e/ ^: ]- M- k
            cursor: pointer;- f* Y/ E$ Z- Z* W6 l# @, N- k. \( q
            transition: 0.3s;; s8 H& O7 U! x, Q) q, I
        }
3 M& O5 o) R1 J# ?7 \# c. h* x/ c% e6 V, f$ ]
        #myImg:hover {
$ E# x0 s% Y" o  g& i" i! m            opacity: 0.7;  R$ O- Q8 {8 R3 }, d- m, b$ Q) A  q
        }( N2 T; W; Q, S! W) C
6 Q4 z& m8 Y- T  Q/ X: d9 }4 g
        /* 关闭按钮 */& [* H1 ]- ]) y' G2 h$ }6 ]
        .close {
$ }2 `) k/ f# D            position: absolute;# @0 h. C) j$ X
            top: 15px;5 T! J* u' m; ], _, h- K
            right: 35px;/ h" ^: q' E5 E
            color: #f1f1f1;
6 `. n2 I, v4 i: W, R" ?            font-size: 40px;7 Q7 P9 e# w& p7 @+ Q* G5 r
            font-weight: bold;" |9 T' ?+ ~* T( L; @+ m4 P5 ]  H
            transition: 0.3s;
8 D& O' Y) l, q+ @) a        }5 B3 N) t6 @1 w6 M; v' ~

& P+ N- a8 Z+ N# U        .close:hover,
/ Z" H7 `1 b( X' X3 [6 V( k        .close:focus {
4 P6 r1 z( ^0 f6 {8 d* |. D! c            color: #bbb;' S" r0 `% g! v( Z& I1 e% C  h
            cursor: pointer;1 ~" s$ _3 V7 _! ], m# O; O
            text-decoration: none;
2 w) _8 c: ?5 U+ b/ H+ U        }$ l1 o& W; E4 l5 x& n. B
    </style>; R' D- @: k) h) T1 X9 N* u/ ^
</head>9 s( x/ k* t! ]4 p  n2 t6 o; W
1 ^, `- S) r' h. G; @7 g1 H
<body>
' V2 q+ a7 z) K- U2 {* ?9 O" z# N, n+ H9 S; L
    <img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">
" M- x8 K3 L5 u" g- ?
& }% Q5 `/ ~/ r/ ~3 P6 H" a6 x9 _$ G% A3 @) f! `% l
    <div id="model" class="model">/ _4 X1 `3 M" p
1 H* z$ y6 |  v! I4 {( a. K

: T" n* m  ]' ~- R# b7 |4 y7 G# `        <span class="close">× </span>
* f* b- v9 z) h% S1 U6 u  \3 y) m1 e$ @! K& n' A
        <img id='img01' class="modelContent">6 V" E% I7 t5 V5 d# ~1 [( Z

4 U7 E+ ^/ @! E' m2 J& \        <div id="caption"></div>) U& N7 O8 v) C' {& x; L
" ]% n4 N! N9 K2 M" @$ |; F# \
0 h$ h# D4 P4 `3 T% s: G
    </div>7 i! y) j7 Z+ F) _" e& x. j3 W

4 ^# A; Y# M5 f$ ~2 w
$ I; I" p7 v% i0 w' `$ U
& c( @; c0 r6 I1 O. d    <script>  p( P3 L/ r* t9 f

3 j7 |, Q+ {2 s$ ~        var imgx = document.getElementById('myImg');
' C" z! C0 q/ `" d. [% @, W' c        var modelx = document.getElementById('model');( o7 N6 y3 b: A
        var modelcontentx = document.getElementById('img01');
$ K- d9 ^. h9 ]/ S& {  g        var captioNX = document.getElementById('caption');2 v+ {! R. H" s: T/ C2 p4 M
$ c) ~, U  L2 A
        imgx.onclick = function () {8 c# d" ^0 H# p8 H
            modelx.style.display = "block";  e; b  G  e! b7 t4 y9 ~, i7 m# f
            modelcontentx.src = this.src;
# ^% v0 e# c9 U) b6 R- D4 J            captionx.innerHTML = this.alt;
0 Q2 `, ]0 G7 [$ D! U. C+ X6 x- C. u1 M& T5 F
        }% f9 V6 T* o& ~5 |; _9 Z. t
+ O& P2 q6 A. v+ G6 C) o& S
3 M/ R1 m3 D/ P' W" w
    </script>; T6 h# m- e* `% Z  g6 u$ m& J0 p

1 y- p7 ?( B; n1 ?7 `% I* o
& s% M0 G" |. l9 X
& z2 X7 b/ o0 t6 {* ^/ M7 S, X% b; F! R; M
</body>6 j& o- A& `/ C8 M

, H8 y- m- b. T# `' o& A) s</html>[/mw_shl_code]1 S8 ?9 A+ \5 Q
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了