【CSS】实现简单易上手的'手风琴效果'

【CSS】实现简单易上手的'手风琴效果'

点击打开视频讲解

<template>
  <div id="app">
    <div class="shell">
      <div class="box">
        <img src="./assets/img1.jpg" alt="">
        <span>图片1</span>
      </div>
      <div class="box">
        <img src="./assets/img2.png" alt="">
        <span>图片2</span>
      </div>
      <div class="box">
        <img src="./assets/img3.png" alt="">
        <span>图片3</span>
      </div>
      <div class="box">
        <img src="./assets/img4.png" alt="">
        <span>图片4</span>
      </div>
      <div class="box">
        <img src="./assets/img5.png" alt="">
        <span>图片5</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'App',
  data(){
    return {

    } 
  },
  mounted() {

  },
  components:{
    
  },
  methods:{
    
  }
}
</script>

<style scoped>
 #app{
   display: flex;
   justify-content: center;
   align-items: center;
   height: 100vh;
   background: #fff;
 }
 .shell{
   width: 90%;
   height: 450px;
   display: flex;
 }
 .box{
   flex: 1;
   overflow: hidden;
   transition: .5s;
   margin: 0 20px;
   box-shadow: 10px 10px 20px rgba(0, 0, 0, .5);
   border-radius: 20px;
   border: 10px solid #fff;
   background: #fff;
 }
 .box>img{
   width: 100%;
   height: 85%;
   /* 对图片进行剪切,保留原始比例 */
   object-fit: cover; 
   transition: .5s;
 }
 .box>span{
   font: 200 45px '优设标题黑';
   text-align: center;
   height: 15%;
   display: flex;
   justify-content: center;
   align-content: center;
 }
 .box:hover{
   flex-basis: 40%;
 }
 .box:hover>img{
   width: 100%;
   height: 100%;
 }
</style>

在这里插入图片描述

在这里插入图片描述

posted @ 2022-08-15 22:27  程序猿咬棒棒糖拽天下  阅读(144)  评论(0编辑  收藏  举报