css3-hover移动效果

"Hello World, Hello Blog"

Posted by wudimingwo on December 15, 2018
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewprot" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>dddd</title>
        <style type="text/css">
            *{
              margin: 0;
              padding: 0;
            }
            .wrapper{
              position: relative;
              
              width: 100vw;
              height: 100vh;
              box-sizing: border-box;
              border: 1px solid black;
           
              padding: 0 10vw;
              
              display: flex;
              justify-content: space-around;
              align-items: center;
            }
            
            .wrapper div{
              width: 200px;
              height: 300px;
              border: 1px solid #CCCCCC;
              
              box-shadow: 2px 0px 3px 2px gold,0px 2px 3px 2px gold,-2px -2px 3px 2px deeppink;
              
              transition: all 0.5s ease;

              background-size: contain;
              background-position: 0 50px;
              }
              
              .wrapper div:hover{
                width: 250px;
                height: 350px;
                transform: translateY(-15px);
              }
              
              .item1{
                 background-image: url(img/test1.jpg);
              }
              .item2{
                 background-image: url(img/2test.jpg);
              }
              .item3{
                 background-image: url(img/3test.jpg);
              }
              .item4{
                 background-image: url(img/4test.jpg);
              }
              .wrapperImg{
                
                position: absolute;
                display: none;
                width: 100%;
                height: 100%;
                z-index: -1;
              }
        </style>
    </head>
    <body>
         <div class="wrapper">
           <div class="item1"></div>
           <div class="item2"></div>
           <div class="item3"></div>
           <div class="item4"></div>
           <block class="wrapperImg"></block>
         </div>
        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
        <script type="text/javascript">
          $(function () {
              $('.wrapper div').hover(function () {
                $('.wrapperImg').hide();
                var bgPic = $(this).css('backgroundImage');
              	console.log($(this).css('backgroundImage'));
              	$('.wrapperImg').css('backgroundImage',bgPic).fadeIn();
              },
              function () {
              })
          });
        </script>
    </body>
</html>