前端页面左右布局,点击左div增加动画过渡效果

编程入门 行业动态 更新时间:2024-10-10 15:22:46

前端页面左右<a href=https://www.elefans.com/category/jswz/34/1770549.html style=布局,点击左div增加动画过渡效果"/>

前端页面左右布局,点击左div增加动画过渡效果

效果图如下

以下代码基于Vue2

<template><div class="container"><div class="left-section" :style="{ width: widthLeft + 'vw' }" @click="toggleRightSection"></div><div class="right-section" :style="{ width: (100 - widthLeft) + 'vw' }"></div></div>
</template><script>
export default {data() {return {widthLeft: 60  // 左侧初始宽度};},methods: {toggleRightSection() {// 切换宽度if (this.widthLeft === 60) {this.widthLeft = 100;  // 隐藏右侧盒子} else {this.widthLeft = 60;  // 显示右侧盒子}}}
};
</script><style>
.container {display: flex;height: 80vh;overflow: hidden;
}.left-section {transition: width 0.3s ease-in-out;background-color: #e0e0e0;padding: 20px;
}.right-section {transition: width 0.3s ease-in-out;background-color: #c0c0c0;/* padding: 20px; */
}
</style>

更多推荐

前端页面左右布局,点击左div增加动画过渡效果

本文发布于:2023-12-06 23:32:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1669348.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布局   效果   页面   动画   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!