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

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

[复制链接]

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

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

admin 楼主

2019-11-7 16:55:28

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

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

x
6 \  k& K' o; D/ N6 b2 b( T
点击图片方法JS动画效果- t3 n; t3 R' S$ {! N7 l
. j3 [9 n5 l6 b* a* p" l/ e2 ]$ a& B$ ^
[mw_shl_code=html,true]<html lang="en">/ k  y8 A. ]+ N- p; }  ]- ^5 a

8 ~1 [6 k7 u8 \9 r4 i, k<head>* l5 v4 W1 n0 v: b
    <meta charset="UTF-8">
, A* V3 B% K% c    <meta name="viewport" content="width=device-width, initial-scale=1.0">
; [! L& x- w! a6 [! g    <meta http-equiv="X-UA-Compatible" content="ie=edge">
$ X3 D, v8 t; V9 L* s' o9 R    <title>Popup Model</title>" q) {1 z8 o+ l  |) {& ?' h

; H8 s2 o& b8 z6 v/ W& @8 w: R  R    <style>0 |+ k/ V4 j* t0 m: V) D
        /* 弹窗背景 */3 _4 @6 W4 `3 k3 C9 y
        .model {# m% j1 J9 {& E( j; L" _2 X5 n
            display: none;
7 S$ q2 k4 i( b9 A7 R* Q- g            position: fixed;. S) C4 K: I" G
            /* Stay in place */
# l5 m$ q$ i! m1 N) x+ y0 }3 e            z-index: 1;! c9 u, L7 [/ G# q  R, H
            /* Sit on top */2 A- `7 [- a" M
            padding-top: 100px;9 n& n$ N1 Z7 l% K+ d4 T
            /* Location of the box */
* r$ c$ \& F, i3 s            left: 0;
8 ?% a" Y; N9 M" b1 P% ?            top: 0;  B7 k1 w8 N( s# h' `
            width: 100%;
- K& o  D) h+ L3 `/ U7 t9 k- S            /* Full width */
9 V: P% l- c& e            height: 100%;/ E' U) I7 h1 C4 P- E1 ~
            /* Full height */3 W( t# }7 s0 P
            overflow: auto;- i- _5 M/ d2 T% P/ x2 h$ ^
            /* Enable scroll if needed */
, e( g5 n' t+ A3 l3 \            background-color: rgb(0, 0, 0);+ r" J. z8 M3 Y7 j
            /* Fallback color */
( d6 E$ ^* p- R, x# d            background-color: rgba(0, 0, 0, 0.9);
, t: I7 g/ A2 h5 Y6 G" J            /* Black w/ opacity *// B$ r7 Q8 V( B( R5 u
        }1 i0 j* T7 A/ Z0 U: q2 _
9 B. q% U2 m7 S! v
        /* 图片 */1 W* r' N* l  S$ W
        .modelContent {
, M% {, C! W/ Z/ D            margin: auto;
$ N/ U6 _7 u4 A, S) c. [            display: block;. y& G7 W9 S$ O0 ?2 B
            width: 80%;
2 }9 A5 I' l* v% Y            max-width: 700px;
  J$ T, p0 F) h* N* @% g1 l2 p0 k; S        }
, `6 J: m6 _6 F3 X8 o) R6 a. D6 I$ D, D; E& [1 Z# B' i
        /* 文本内容 */
0 P; Q% g4 m3 X# i! |" W        #caption {
+ k6 E7 C, L: |, }& `            margin: auto;' {9 X" X# }9 I1 Q# C" O6 |
            display: block;
) Q) q. j$ @5 {            width: 80%;. Y8 p/ ~& ?) u& c, ?" ]
            max-width: 700px;
: C/ G# Q3 K% W% M/ @            text-align: center;7 D- a7 C" k1 L0 t4 @
            color: #ccc;3 Q2 Z* n9 c: u1 ?
            padding: 10px 0;' v- U' {/ V1 R
            height: 150px;! U, [/ D- {0 p& A
        }
" \8 m4 d' A9 y1 v0 M       /* 添加动画 */: r7 \! q2 K. c( i; N/ C+ X! R
.modelContent, #caption {  
  c1 `1 F+ _. V: b0 k9 f! ?% ]    animation-name: zoom;
7 l6 D2 n. \# L    animation-duration: 0.6s;
5 m8 y, q% [) @    -webkit-animation-name: zoom;( _" L9 x6 Q$ a" z, V& \! W$ j
    -webkit-animation-duration: 0.6s;
% u3 C" z. F- M5 I}2 x- A# J$ H* k) d

5 d0 @, x# `# p, N@keyframes zoom {% v* y; t& S5 V1 Q* G: S2 P% s
    from {-webkit-transform:scale(0)}
6 l# N$ W$ J" ~    to {-webkit-transform:scale(1)}& i8 f$ S7 n4 H6 c5 Q& j+ t
}: B$ C& q8 c. Z9 G5 v" |
! Q  _, D' ?8 h) S% E6 R& o
        #myImg {
0 v6 k+ f% d  ^5 w/ \$ n: O            border-radius: 5px;. O3 M8 A7 i+ u
            cursor: pointer;
. J% O) c' T, d. `  }8 [& G            transition: 0.3s;5 C) G5 `1 _' N+ s3 |
        }
* h/ i8 o$ n+ c% ?, g6 R. J8 [7 b8 G$ w: Q
        #myImg:hover {
7 v1 I+ e5 B- r4 p4 m4 l            opacity: 0.7;5 J! ^1 K/ [' U6 j' M1 u  t( e
        }- ^9 j( L( @( \6 i8 S

: v) N; ^3 g9 q* d! K) |6 C! F        /* 关闭按钮 */- j4 t; c+ i7 C6 @8 d3 _, c
        .close {
4 G" i2 ~( G7 O) B+ U$ E            position: absolute;+ d% P9 K' X5 M2 j
            top: 15px;
9 N' B6 ]7 b1 X8 u            right: 35px;! E" e5 _( h; C8 f3 y
            color: #f1f1f1;( ]# k# I0 X# m5 m
            font-size: 40px;
$ ~! r1 s0 k. u# G4 `- K            font-weight: bold;
' u& p. F% q: ]" E& r            transition: 0.3s;* O; L; L9 Z/ Z; @8 n
        }
9 [5 r- n1 M+ N9 d7 _- [2 v* {  R5 n$ q# A
        .close:hover,
1 X1 }' b# k- F4 D* r" H+ Q        .close:focus {. E' ~( Q/ |. n6 v* H, i1 }
            color: #bbb;. n" Z" C8 o8 e! d9 C; ?1 O1 Y4 y
            cursor: pointer;* |9 n4 ]5 L6 H* k
            text-decoration: none;2 n; @2 }8 {! H: n" f
        }5 R) e3 `3 L$ Z, p( f4 N
    </style>, u3 O3 `$ j! f2 X5 e( U. U
</head>
" o5 q9 Q9 L8 L$ j+ @% g
9 i# C0 G$ a; b+ b4 s9 S$ s<body>, o1 [# n: m8 K+ ?! \: `
, K2 s6 ?; ?4 w9 M2 l3 p
    <img src="./img/Logo.png" alt="This is a logo" id="myImg" width="300" height="200" alt="This is a test ">8 {# [* }/ {. I4 H! v

; {6 X; h$ s$ B. D6 |
7 G; m& H$ d# }; B2 B    <div id="model" class="model">6 I7 L: Z, ?4 T( I. ^0 d

) K* F( ^. n5 f
0 h9 |. t8 ?3 P        <span class="close">× </span>" h  E7 t& d1 i/ i

+ @2 r* e& K" w/ x; p% f. z        <img id='img01' class="modelContent">. [1 H; F6 W4 j* N; C5 {9 D+ Q* `

1 G! L1 b: I  A$ ~" d& z  ^1 b        <div id="caption"></div>
+ Y) [6 C# s- m* @' \4 l
5 B# D  V& k  d) Z6 K( Q' o3 \% L6 B7 ]0 ~! x5 o5 G3 h5 l
    </div>1 P$ e" \* r$ |) ~
+ F; p8 ^- V$ y! `0 i

0 q% m  b4 i1 k$ J; _
  o: ?/ {; g2 Z* Y+ \1 a6 t9 e3 a+ w8 R    <script>
; g$ E7 f' o. Q0 {4 {0 V
, ^* d$ s0 x: K; p2 E        var imgx = document.getElementById('myImg');
. P- f6 n( e  s        var modelx = document.getElementById('model');
* f" K7 \# q3 Y8 b        var modelcontentx = document.getElementById('img01');
) u3 R7 \$ X( o5 Q        var captioNX = document.getElementById('caption');/ d1 X/ K; _5 o( X, e
8 v# `% M! a* Z8 t) E( ^" G+ l- K/ E
        imgx.onclick = function () {9 D3 c' E! v9 n/ ~: G5 J/ H* u
            modelx.style.display = "block";' C; R7 G+ J6 L
            modelcontentx.src = this.src;
. I. Q5 H- l4 }- O1 n, G            captionx.innerHTML = this.alt;* ~$ D$ f: B  [+ F
/ U" u) j) y  L  X' ?
        }
6 p4 _( Q7 [- @/ [5 V9 T; D, o0 l9 r" I. ~  T

7 C3 J8 A9 ]/ K* A8 C) m1 t    </script>
7 ~* R) O2 A; P$ {9 A  X" L" o: u4 u' C+ r3 R
" Q, Y) V  I) x' x/ y4 d! H- L" Y
: c' s) r3 @7 W* w7 b* {
! v' U/ z! n& X$ S+ L1 y
</body>9 a+ s$ G" E. a. J2 `; @) e5 l

! `; ^* D9 i8 ?</html>[/mw_shl_code]
( w( O  B6 G3 K9 h/ X
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了