【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>
标签:box,flex,center,height,易上,fff,手风琴,CSS,图片
From: https://www.cnblogs.com/mochenxiya/p/16589905.html