利用平移-transform, 设置元素浮动效果

 1     <div class="box">
 2       <div class="box1"></div>
 3       <div class="box2"></div>
 4       <div class="box3"></div>
 5     </div>
 6 
 7   .box {
 8     display: flex;
 9 
10     .box1,
11     .box2,
12     .box3
13      {
14       width: 200px;
15       height: 200px;
16       margin: 10px;
17       
18       transition: all .2s;
19     }
20     .box1:hover,
21     .box2:hover,
22     .box3:hover
23      {
24       transform: translateY(-10px);
25       box-shadow: rgba(0, 0, 0, .3) 0 10px 10px;
26     }
27 
28     .box1 {
29       background-color: slateblue;
30     }
31     .box2 {
32       background-color: skyblue;
33     }
34     .box3 {
35       background-color: pink;
36     }
37   }

 

posted @ 2021-11-16 19:27  dahei  阅读(43)  评论(0)    收藏  举报