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

50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | Rotating Navigation (旋转导航)

📅 我们继续 50 个小项目挑战!—— Rotating Navigation 组件

仓库地址:🔗https://github.com/SunACong/50-vue-projects
项目预览地址:🔗https://50-vue-projects.vercel.app/


在这里插入图片描述

✨ 组件目标

  • 🌀 实现一个旋转按钮动画菜单,点击按钮后页面整体旋转并展示侧边菜单
  • 📱 菜单项带动画滑入效果,按钮提供“展开/关闭”两种状态
  • 🎯 运用 transitionrotate 动画提升用户交互体验

🧱 技术实现点

  • 使用 Vue 3 + ref 实现菜单状态管理
  • 使用 Tailwind CSS 实现旋转、位移、过渡、定位等动画效果
  • 组件内嵌头部内容模拟文章内容(用于旋转效果展示)
  • 左侧导航使用 translate-x 控制菜单显隐

🔧 RotatingNavigation.vue 组件实现

<template><div:class="['origin-top-left bg-white transition-all duration-500 ease-in-out',turnRotate ? '-rotate-30' : 'rotate-0',]"><div:class="['fixed -top-20 -left-20 transition-all duration-700 ease-in-out',turnRotate ? '-rotate-[65deg]' : 'rotate-0',]"@click="turnRotate = !turnRotate"><div class="h-40 w-40 rounded-full bg-fuchsia-300 text-white"><button class="absolute right-10 bottom-7 text-3xl"></button><button class="absolute bottom-8 left-8 text-3xl">×</button></div></div><div class="mx-28 flex flex-col items-start gap-2 px-50 pt-30"><h1 class="head-text">Amazing Article</h1><small>Florin Pop</small><p class="base-text mt-4">Lorem ipsum dolor sit amet consectetur adipisicing elit...(略)</p><h3 class="sub-text mt-4">My Dog</h3><imgsrc="https://images.unsplash.com/photo-1507146426996-ef05306b995a"alt="doggy" /><p class="base-text">Lorem, ipsum dolor sit amet consectetur adipisicing elit...(略)</p></div></div><div><nav:class="['fixed bottom-40 left-0 z-10 text-white transition-all duration-500 ease-in-out',turnRotate ? 'translate-x-0' : '-translate-x-[200px]',]"><ul class="list-none pl-8"><li class="my-10 uppercase transition-all duration-500 ease-in">🏠 <a href="#">Home</a></li><li class="my-10 translate-x-4/12 uppercase transition-all duration-500 ease-in">👋 <a href="#">About</a></li><li class="my-10 translate-x-8/12 uppercase transition-all duration-500 ease-in">📧 <a href="#">Contact</a></li></ul></nav></div>
</template><script setup></script>

💡 Tailwind CSS 样式重点讲解

类名说明
rotate-0 / -rotate-30控制容器旋转角度
transition-all duration-500添加平滑过渡动画
translate-x-0 / -translate-x-[200px]控制菜单移入移出位置
fixed / absolute控制定位,便于按钮和菜单固定显示位置
ease-in-out / ease-in设置动画速率函数
rounded-full / bg-fuchsia-300控制按钮样式

🦌 常量定义 + 组件路由

constants/index.js

export const projectList = [{id: 3,title: 'Rotating Navigation Animation',image: 'https://50projects50days.com/img/projects-img/3-rotating-navigation-animation.png',link: 'RotatingNavigationAnimation',}
]

router/index.js

{path: '/RotatingNavigationAnimation',name: 'RotatingNavigationAnimation',component: () => import('@/projects/RotatingNavigationAnimation.vue'),}

🚀 小结

本组件通过 rotatetranslate 结合 Vue 的响应式状态,构建出一个带旋转动效的侧边导航菜单。

  • 💡 利用 Tailwind 的 origin-top-left 实现旋转中心
  • 🎬 点击按钮时,实现 rotate + translate 的流畅转场动画
  • 🧠 实现简单逻辑切换,用户体验感强,交互感十足

📅 明日预告:Hidden Search Widget!用一个按钮展开搜索框。

每天造一个轮子,码力暴涨不是梦!🚀

http://www.xdnf.cn/news/7504.html

相关文章:

  • 新浪《经济新闻》丨珈和科技联合蒲江政府打造“数字茶园+智能工厂+文旅综合体“创新模式
  • Python、Pytorch、TensorFlow、Anconda、PySide、Jupyter
  • 欧拉系统离线部署docker
  • iOS苹果和Android安卓测试APP应用程序的区别差异
  • 【Linux】进程间通信(三):命名管道
  • 嵌入式开发学习日志(linux系统编程--文件读写函数)Day24
  • vr制作公司提供什么服务?
  • Linux跨网络通信中IP与MAC的作用
  • Electron+vite+vue3 从0到1搭建项目,开发Win、Mac客户端
  • spark调度系统核心组件SparkContext、DAGSchedul、TaskScheduler介绍
  • 项目管理进阶:基于IPD流程的项目管理部分问题及建议书【附全文阅读】
  • 怎么样进行定性分析
  • 交通拥堵预测器(python)
  • Linux云计算训练营笔记day11【Linux CentOS7(cat、less、head、tail、lscpu、lsblk、hostname、vim、which、mount、alias)】
  • Python训练营打卡——DAY30(2025.5.19)
  • 苹果的人工智能领域慢热
  • esp32课设记录(三)mqtt通信记录 附mqtt介绍
  • thinkphp6实现统一监听并记录所有执行的sql语句除查询外
  • 2021-10-29 C++求位数及各位和
  • MathType公式如何按照(1)(2)…编号
  • 定积分的“偶倍奇零”性质及其使用条件
  • 软件设计师“关系模式和关系代数”真题考点分析——求三连
  • Mergekit——高频合并算法 TIES解析
  • C 语言学习笔记(函数2)
  • 【实战教程】如何添加git仓库的子模块
  • ipynb文件的一键访问(顺带启动jupyter)实现程序演示
  • Excel导入校验
  • 获得AI相关认证证书对个人职业发展的具体帮助有哪些?
  • mybtais plus使用拦截器打印完整SQL语句
  • Pyro:基于PyTorch的概率编程框架