当前位置: 首页 > news >正文

grid布局下的展开/收缩过渡效果【vue/已验证可正常运行】

在这里插入图片描述
代码来自GPT4o:国内官方直连GPT4o

<template><div class="container"><button class="butns" @click="toggleShowMore">{{ showAll ? '收回' : '显示更多' }}</button><transition-group name="slide-fade" tag="div" class="grid"><div v-for="(item, index) in displayedItems" :key="item" class="grid-item">{{ item }}</div></transition-group></div>
</template><script>
export default {data() {return {items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9'],showAll: false};},computed: {displayedItems() {return this.showAll ? this.items : this.items.slice(0, 6);}},methods: {toggleShowMore() {this.showAll = !this.showAll;}}
};
</script><style scoped>
.butns {position: absolute;top: 100px;left: 0px;
}
.container {display: flex;flex-direction: column;align-items: center;
}.grid {display: grid;grid-template-columns: repeat(3, 1fr);gap: 10px;overflow: hidden;
}.grid-item {background-color: #f0f0f0;padding: 20px;text-align: center;border: 1px solid #ccc;
}button {margin-top: 20px;padding: 10px 20px;font-size: 16px;cursor: pointer;
}.slide-fade-enter-active, .slide-fade-leave-active {transition: all 0.5s ease;
}.slide-fade-enter, .slide-fade-leave-to {max-height: 0;opacity: 0;margin: 0;padding: 0;
}.slide-fade-enter-to, .slide-fade-leave {max-height: 200px; /* Adjust based on your content's height */opacity: 1;
}
</style>
http://www.lryc.cn/news/393947.html

相关文章:

  • Qt/C++编写地图应用/离线地图下载/路径规划/轨迹回放/海量点/坐标转换
  • 最新版Python安装教程
  • 1.3镜像管理
  • 黑马|最新AI+若依 |初识项目
  • ArrayList综合案例-模拟外卖中的商家系统
  • Postgres JSON字段怎么修改key的名称
  • GStreamer学习5----probe数据探测
  • Open3D 点云的圆柱形邻域搜索
  • python如何设计窗口
  • C语言获取当前时间
  • 【每日一练】python三目运算符的用法
  • CentOS 7.9 停止维护(2024-6-30)后可用在线yum源 —— 筑梦之路
  • Git 常用命令备忘
  • Ubuntu24.04安装Skynet环境
  • 【C++】cout.self()函数
  • VueQuill 富文本编辑器技术文档快速上手
  • 链式二叉树oj题
  • Curator 是一个开源工具为 Elasticsearch 集群设计,用于自动化索引的维护任务。
  • STM32-PWR和WDG看门狗
  • C++循环队列 经典示例
  • 【程序大侠传】大表分库分表切换数据库类型导致pagehelper生成sql语法报错
  • 7、Redis 队列与 Stream
  • FFT剖析
  • git clone报错RPC failed; curl 92 HTTP/2 stream 7 was not closed cleanly
  • Apispec,一个用于生成 OpenAPI(Swagger)规范的 Python 库
  • SpringBoot 自定义异常返回数据格式
  • 【xinference】(15):在compshare上,使用docker-compose运行xinference和chatgpt-web项目,配置成功!!!
  • 【Unity 3D角色移动】
  • 个人视角,社会影响力:自媒体的魅力所在
  • 算法训练营day70