PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2019-11-7 16:55:28

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

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

x
  _# d+ \5 `  h$ A- `
点击图片方法JS动画效果
8 H; O. j; K9 q6 J( w" T; x+ L* e! W1 d/ U/ L
[mw_shl_code=html,true]<html lang="en">
/ N+ `& t) t5 i0 Y$ T& `
1 s1 U% d/ l. e<head>
* S$ X8 r/ K; u: S( M8 S/ O    <meta charset="UTF-8">3 F( G, e$ y) u0 {; f
    <meta name="viewport" content="width=device-width, initial-scale=1.0"># Z% N( }* a! Q5 F+ h7 M( K
    <meta http-equiv="X-UA-Compatible" content="ie=edge">2 D2 R) V) H  ^8 V" d! H1 y5 |" }: y
    <title>Popup Model</title>
: o0 r& F0 v4 C9 r6 k1 e% `! P) p$ ^
    <style>! A7 ^: ~3 g- h6 K# ~2 J9 p2 E7 }
        /* 弹窗背景 */- J. F% L2 M6 @& d2 Q
        .model {1 Z8 l, c4 K! q6 R3 _, R4 p
            display: none;
% i0 }. i& X4 l% \' W% V7 \; r, V            position: fixed;5 S- i9 n8 B4 j. g
            /* Stay in place */
% O8 ?- O  J7 H! I  A            z-index: 1;
9 Q, G3 i4 s: b2 C9 Z2 T/ n            /* Sit on top */
" p, X& l. B$ u' @1 |            padding-top: 100px;
9 m9 N# S2 i  s9 a1 j            /* Location of the box */6 R! p6 V- a% O& Y: Y- X  x
            left: 0;
  g8 P* P- A  p            top: 0;' L* G6 E' T; v! @- \* s* U
            width: 100%;
$ ?/ b* g  C; }2 _5 q            /* Full width */
, ?, a; H( B' a8 B# r1 Q            height: 100%;
! N& r: w) w7 u' g: Z! \            /* Full height */
0 k9 S9 @, F/ F8 @            overflow: auto;3 Z- m2 u; P' P+ P9 D
            /* Enable scroll if needed */: Q1 c$ s+ c6 O% e) }, H
            background-color: rgb(0, 0, 0);/ w  B" [4 y3 W& }' ^, q" r1 `
            /* Fallback color */! X8 ~" h+ I+ `9 L, q& [
            background-color: rgba(0, 0, 0, 0.9);$ q# G' F* S9 o9 Z
            /* Black w/ opacity */" z' j* q; X0 C
        }4 k/ ]# x6 M- Q6 F
8 i3 @% e% u4 B
        /* 图片 */
) o1 w  Z+ D7 w- Y+ u; l" y        .modelContent {0 W/ c0 n3 M3 Y. o' H" G
            margin: auto;
$ R, A6 l# i  N            display: block;
5 `; K% k  p: ?4 V' d- P) ]# U            width: 80%;( B" ]3 h+ B, _/ Y
            max-width: 700px;
9 d) l8 Z* I+ ^+ `& B. N' v9 N6 O        }
- S- s1 L0 A5 K. `3 m5 @% L% Z3 t# {# M* {, h
        /* 文本内容 */
+ Z3 Z: x! Z& @- B        #caption {4 W* J& ~8 s* G5 Y! d9 q
            margin: auto;
; l% ~# @  c# C! {            display: block;5 I+ N/ |' g4 L
            width: 80%;
  d$ B, U& D% ~            max-width: 700px;* t# m) i3 u6 N: O; s6 \0 x/ k
            text-align: center;
9 |- B/ E' R  E/ p) s7 p8 H9 Z8 Q            color: #ccc;# Z5 l/ @# g5 b% y- z  l1 _$ S
            padding: 10px 0;- c! v& {2 D0 v6 q9 x
            height: 150px;& f( v# n0 q* V5 e5 s
        }
' E! w3 W4 e3 i) D8 z9 V! Y       /* 添加动画 */
3 r$ T! }$ l/ z3 T" O.modelContent, #caption {  ( A' ?2 m/ T" N" U. _
    animation-name: zoom;
  M/ q" u1 f0 _5 B' y    animation-duration: 0.6s;) j7 A$ }6 D4 y( i: R
    -webkit-animation-name: zoom;
  z1 r; ?( d: w% ~+ D7 l    -webkit-animation-duration: 0.6s;( Y2 B7 R6 c6 `3 V% n& P9 w
}
: g& X" |  b* X) m
2 K( N  q" \- M+ w@keyframes zoom {. D4 J$ l) I, h/ [; X4 v
    from {-webkit-transform:scale(0)} # s) F2 r1 O& T$ L6 h2 M
    to {-webkit-transform:scale(1)}
6 h* H( S) P/ ]! [9 ^}
: Q( Y1 a9 G3 {7 u4 a9 e3 a9 G2 L8 X, l, X
        #myImg {9 z6 c  i( {* t4 [& C8 G
            border-radius: 5px;
" X) P2 C9 K3 r( K9 n4 K            cursor: pointer;
2 Q9 B" U3 ~+ t% V7 H4 q            transition: 0.3s;
. k- w* U% w; r7 J/ l4 C+ [        }. O; Z3 s4 o% i

3 K% k& {) ^  h* C7 Q; q5 l0 {3 Z        #myImg:hover {. l1 b+ h  ?5 x/ ]) J! L" [- j
            opacity: 0.7;( s7 I" K$ q9 \! Y* d" a
        }) ?5 _- H* t0 Q& [0 J" ?
$ `1 p# G; ^- L% K8 V% l, C4 x
        /* 关闭按钮 */; e. q* ?6 S% {7 Y) h  y9 Y# F
        .close {+ \4 `. n9 j3 ]
            position: absolute;! {/ k2 j# r! w$ D* v
            top: 15px;
$ N3 t% p8 m/ G6 w1 R) U/ |            right: 35px;9 A) e' Y* W5 n. ]+ C2 G6 O0 V$ O+ W
            color: #f1f1f1;
# H: x7 _/ B$ ^- v            font-size: 40px;
2 {# J! b( c  j            font-weight: bold;
) d9 v' b. m& w            transition: 0.3s;8 A4 s  j' Q3 F& ]& M
        }. I) {3 [6 f: p/ }3 r. o

, p$ v5 q4 _3 \; h  U. P        .close:hover," q9 d5 B9 v8 {5 P4 n# q
        .close:focus {
, C1 A/ g3 a) t( b1 w            color: #bbb;/ C3 ]0 h4 Z, A! ^/ D% D+ k
            cursor: pointer;
3 X( ^& Q3 {  @$ t' ~% v            text-decoration: none;
9 e3 {% R: R2 D& R( l* ^! @        }
1 U; c4 X0 T! y6 E    </style>! v2 E: ]7 w% h; t) I
</head>
: d( F2 F! Z( x  N4 `* d/ u, l! Z2 h" w4 X
<body>
- M3 q3 }3 x2 m; g8 I
  \/ W, B9 K4 z! W& h; h' i& \- g    <img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">
, C6 N2 U; W: l% l% W  c! A& _) {6 w' ~* e7 I, ]1 \! c: a

! c5 L, l& a7 T! R    <div id="model" class="model">( s- E4 H7 u0 _1 |: x; A' }

) D' d2 I+ H3 W( X3 ]% i/ _$ n+ s) l" _( A2 ?6 a
        <span class="close">× </span>
1 [7 @4 {8 y; z5 i, F& R" ?' d
/ |. W% R* A( v6 Q& O        <img id='img01' class="modelContent">7 b: k( |0 i) H- s

- Z& G. G) p+ J" `2 K- z        <div id="caption"></div>
. T$ q- M* T' ?& E8 p# a8 d- J+ M
. C& J9 A& `9 q0 d% C# e
: q$ ~6 r; h5 r% X5 X% f3 N2 `! K; s    </div>& r' z8 P) D, A' U6 p; N7 t5 n

" e, _8 c  d4 r1 {5 c3 T( j( U2 k/ _1 F- j) q

& @2 |: x* K( G    <script>
/ Y* F: ~2 k; X
5 h- X% p3 g+ x0 l        var imgx = document.getElementById('myImg');8 T& I/ K8 C0 |/ W
        var modelx = document.getElementById('model');# k. z5 n* |! G0 {5 v8 L9 H9 e
        var modelcontentx = document.getElementById('img01');
. t: y2 s9 b# ^7 E9 j. i        var captioNX = document.getElementById('caption');
9 j0 u* T# T4 N  t9 C
' Q2 Y& N. a- a' p        imgx.onclick = function () {
! R  e. u" K( G+ [3 l: b            modelx.style.display = "block";
5 ?% c1 i# ]8 C2 A9 v! G% ]  B            modelcontentx.src = this.src;
3 e5 m" ]/ c2 o1 }5 y            captionx.innerHTML = this.alt;! ]6 x3 x( |5 [+ X

# k. w8 I, h5 S$ h        }
3 \; p0 ]1 i* F% M, S5 ~& [, \/ P/ _. h# j/ u
8 h+ N& P  a; B, J8 [3 `" }
    </script>
5 e. B6 w$ G% S5 |; s, F9 q! W; r! C4 D
2 z+ J6 |& d6 b8 ~1 r
) |5 C9 j8 J; ?" ^+ E3 o3 k

# m* m$ W! z# z% u</body>% Z' w6 E; i7 }; D- R
/ S: K! ]0 Y& s) ~
</html>[/mw_shl_code]
5 A  J* n7 v- G: r7 P
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了