PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2019-11-7 16:55:28

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

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

x
- q8 z9 F  G1 `3 k0 _+ b: n- n
点击图片方法JS动画效果
, Z: q$ R) l, a. R! ?8 r+ O* [+ L) k! _' f, A
[mw_shl_code=html,true]<html lang="en">7 ~2 H# \! h6 j  t7 M+ k/ A3 T. ^, C

0 _0 K6 E* _. R4 @( m7 m9 |, E0 Y<head>
( k# E1 y. F# p    <meta charset="UTF-8"># A- M# k& W$ }$ V2 i
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
3 }6 K9 b" W% L6 A4 f1 U    <meta http-equiv="X-UA-Compatible" content="ie=edge">
: N4 g9 Y% O! V$ h/ Q1 p% f: U4 S    <title>Popup Model</title>
: ?; p, k# |1 A) \8 Y5 B5 X. J: S# k5 n" h3 a6 V
    <style>
& f: W, X  p2 `4 @# b& R9 i& D! `        /* 弹窗背景 */
! s: z! m! L3 k+ |$ P( T$ F% c( K        .model {9 {+ O! I6 ~. i! H0 M9 K) D
            display: none;1 d/ x/ o4 G0 R2 f$ F% r7 |6 K1 T
            position: fixed;
# s* \# G8 Q, _* o            /* Stay in place */! _# p% c1 V9 ~8 _: j1 W# A! q
            z-index: 1;: r/ F8 X) F$ n7 M) }- y+ ^3 I
            /* Sit on top */
( h) q8 ?+ N0 Q( X& W            padding-top: 100px;; z" b! M# D$ x9 c6 p" E, t
            /* Location of the box */7 C9 W% [; i6 A7 g
            left: 0;, O1 x; U% ^/ X  h. n( L
            top: 0;
  d, K, \2 M8 P            width: 100%;
: M8 j( x. P1 T5 @2 {            /* Full width */3 z2 D( C( u9 K7 l, Z2 G$ p' O
            height: 100%;
; l. h" n) D  r9 T' g7 A            /* Full height */
5 ]2 E  d2 q+ K" A3 ?( P5 ]            overflow: auto;5 x! V1 i" ]9 F, I" q1 u# @( {# C& u
            /* Enable scroll if needed */
" O) X& {, m$ X/ S( o/ `% B            background-color: rgb(0, 0, 0);
# p( x9 b, d) R7 N            /* Fallback color */
0 z- w, s  {6 d" E            background-color: rgba(0, 0, 0, 0.9);
* l# ^# r3 s6 L$ X3 m, \5 R            /* Black w/ opacity */
! x) {! G* l( F1 T! S        }9 W, ^) \0 e1 {- S- R
* A% Y& ^( [; X4 X; y& h8 [
        /* 图片 */
2 ]) x4 G# g7 e! Q0 w4 p        .modelContent {3 j6 L& c! m2 t0 ]3 n2 I
            margin: auto;1 @8 Z+ Q- R. P; f! v2 Y
            display: block;& M# c1 ~9 _# q. L3 x, @* t) X) o
            width: 80%;
' b4 h5 z' _% i4 p            max-width: 700px;
6 D( \2 E$ Y0 F, ^& n        }
+ {! n2 i+ ^6 e  }5 o# x6 u4 i
: T  \/ K7 Z, y; C! S        /* 文本内容 */
$ {! C) G: Z6 b% |5 V* a7 ?        #caption {
1 G& [$ c+ t$ Y( W' n4 X            margin: auto;) _( @# |, B# P3 i" v
            display: block;
: g6 ~) ^! |1 V& `            width: 80%;
9 J0 s8 B" }& l# T! E3 v            max-width: 700px;1 E2 S7 j% X9 C: k0 ?& A8 b
            text-align: center;" B0 B4 x* b6 U0 a
            color: #ccc;- u. U: f# x1 ]) a+ `) l) N* j
            padding: 10px 0;) h' d+ P" `/ h
            height: 150px;
; Y- T, f, y# ?        }
) D7 c, ]3 s) L+ I3 k  |$ T& Z       /* 添加动画 */
: X. I  T8 Q, b( @.modelContent, #caption {  ' z3 c! I1 i; O$ p, Z6 s5 x9 I$ Q
    animation-name: zoom;) y2 }6 g+ S* N
    animation-duration: 0.6s;
& [5 u# d3 t* T: E6 y2 v    -webkit-animation-name: zoom;
. r" G3 o7 ~: k( y, J! z# e& f    -webkit-animation-duration: 0.6s;
5 M- e2 v, U! B" @}
8 ~7 |% c. D8 g, X# {2 P% ?! Q1 m" z- n3 D! }
@keyframes zoom {
% m' J3 e6 _1 t+ H/ x    from {-webkit-transform:scale(0)} & D# ]! j+ A9 a  ~
    to {-webkit-transform:scale(1)}3 c2 ]) C! x  J) j* `8 F/ `; s& i$ W
}
' m: ]# ~& a- Q+ C: G' ^& }; L8 ^0 E  N7 V
        #myImg {# V7 ]2 m5 ?% t, ^3 K( {
            border-radius: 5px;
$ R8 u4 \; n( }2 j            cursor: pointer;
9 O2 b' j2 l9 F: t! h: W2 t            transition: 0.3s;
, v+ b& H. K9 N4 @& K' U* V        }
! ^  S2 O% Q: k
. o5 a$ a% v4 z6 l        #myImg:hover {
9 f6 e! I4 Q( z6 q" q9 i            opacity: 0.7;$ B" B! O% C6 `( Q% x1 m; Q! o
        }
: U& @7 Y/ s6 p. N
3 Q, {. O* k& `7 X7 S6 p        /* 关闭按钮 */
  t' P1 _8 r) N  r- `- @4 l        .close {
* S+ Z" k( t: |' y$ J6 W            position: absolute;8 G- w) _, r& ?3 I
            top: 15px;, `$ T7 _; Q9 }6 N/ |
            right: 35px;, Y5 }2 P. s2 u
            color: #f1f1f1;
$ A, f5 @0 v, Q* m9 t2 T            font-size: 40px;3 z0 ^# O  x3 D( V" e
            font-weight: bold;
  k- u, i" F) ~: `2 }2 K5 e            transition: 0.3s;$ v; E; n% h( ]. I/ @
        }/ W0 J7 V' s$ ]
! Y5 m, k4 |$ v6 f  e2 K( O4 O4 t
        .close:hover,* v1 t$ W  W5 |. }' u. s8 Y% J
        .close:focus {
; I- n/ T+ D6 B9 ~2 _            color: #bbb;. `% P+ n; l# a* K$ Z& p. _. [: l
            cursor: pointer;) w" _! n5 Y( Q5 p6 f4 `* z6 j
            text-decoration: none;* V' V* v. G& H3 k4 A0 q. t$ B' P; g
        }# J5 o6 j0 g: @9 {, F2 I
    </style>
! n& n3 ]5 l2 Q& U* h7 f8 B/ J</head>2 A3 N1 `8 d' @5 E% @8 d7 O  Z8 m

; H; c2 o. e1 _/ c<body>+ n' C/ k1 G% `$ ~

, t, g* p8 ~$ M2 L/ V5 N    <img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">
# U& R( Q) l. N; ^: j" w. U* P4 G* y: G$ B

, g7 A( w# T% m    <div id="model" class="model">$ L2 _  ]8 s+ W/ [! l5 \
$ f2 J8 x: L2 }; j8 `
( l) z8 D- w$ z! {6 P: e
        <span class="close">× </span>  f, ~. V% A! H& s1 W5 r6 ]
  I3 w$ m5 c8 I/ o0 A
        <img id='img01' class="modelContent">
9 h# N# o6 \0 |8 U* E- y7 q8 N  ~
        <div id="caption"></div>5 {  w5 B3 ~% e1 h
2 V# ~, `( N% e7 T: [* b, \! v
" e) R( Y6 A; k+ }
    </div>
0 k2 V" H, W0 G, @5 C. B  v+ I6 q; F9 \: j7 l8 g2 `- f

# Y1 y- \' l$ w4 `0 k
1 F6 h! W" A7 ]    <script>
, l# R. [+ Y% J, y# w3 r) F4 E+ g, R# @) R! P$ N& k# a
        var imgx = document.getElementById('myImg');
& P9 j) p. @# S; m        var modelx = document.getElementById('model');
$ f# q/ l, h4 w$ G5 `        var modelcontentx = document.getElementById('img01');7 |" }. x% W% h; S8 |$ u5 u! P
        var captioNX = document.getElementById('caption');' @# S( a. P; ^2 S

2 d# W& @1 s: G. k7 v! \0 \        imgx.onclick = function () {
6 u. f0 \" Z  R/ a, S6 s7 w            modelx.style.display = "block";8 K' k" T( j/ z
            modelcontentx.src = this.src;
, r- z! C8 Z9 T# w8 R5 q            captionx.innerHTML = this.alt;8 U7 _4 Z; |) q  }  }& g

# v( V6 ]( k5 u2 F  j        }
# C* a4 C# C- u1 }; e+ F
0 t& m# G& D) o. \4 s% E, i$ ^, v8 U2 l2 p: D
    </script>& Z* c5 u$ [& P; ?# E4 _( C$ |& W
- e  _2 W; g, l9 |! g' l9 J  s
2 y3 ~' A/ a8 v5 V

3 Q3 {8 Q% f& A2 {  Q. _, d' T1 e
</body>
% l# o& L( x. }4 n) `
4 ~1 I7 {' |- A' s. m</html>[/mw_shl_code]* F. Q; r$ O2 G0 Z. B
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了