这篇文章主要讲解了“Vue+animation怎么实现跑马灯效果”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“vue+animation怎么实现跑马灯效果”吧!1、单行显示,每行只显示一条效
这篇文章主要讲解了“Vue+animation怎么实现跑马灯效果”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“vue+animation怎么实现跑马灯效果”吧!
1、单行显示,每行只显示一条
效果图
上代码
<template> <div class="container"> <div class="box"> <!-- 假设lists列表有4个项,设置ul的宽度为800%(相对于box),设置li的宽度为12.5%(相对于ul是12.5%;相对于box是100%),但是li要有8个,其中4个是复制的,用来占位 --> <ul :> <li : v-for="(item, index) in lists" :key="index"> <div class="content">{{item.name}}</div> </li> <li : v-for="(item, index) in lists" :key="index"> <div class="content">{{item.name}}</div> </li> </ul> </div> </div></template><script>export default { name: "activity", data() { return { lists: [ { name: "马云阿萨" }, { name: "雷军的" }, { name: "王勤啊啊啊啊" }, { name: "等伦伦" } ] }; },};</script><style scoped>.box { width: 100%; height: 0.6rem; background-color: #b32855; overflow: hidden;}.box ul { animation-name: move; animation-timing-function: linear; animation-iteration-count: infinite;}ul li { float: left; height: 0.6rem; display: flex; align-items: center;}ul li .content { height: 0.4rem; padding: 0 0.2rem; border-radius: 0.2rem; background-color: rgba(0, 0, 0, 0.2); color: #fff; display: flex; align-items: center; justify-content: space-around;}@keyframes move { 0% { transfORM: translateX(0); } 100% { transform: translateX(-50%); }}</style>
2、单行显示,每行显示多条
效果图
上代码
<template> <div class="container"> <div class="box"> <!-- 假设lists列表有4个项,设置ul的宽度为400%(相对于box),设置li的宽度为12.5%(相对于ul是12.5%;相对于box是50%),但是li要有8个,其中4个是复制的,用来占位 --> <ul :> <li : v-for="(item, index) in lists" :key="index"> <div class="content">{{item.name}}</div> </li> <li : v-for="(item, index) in lists" :key="index"> <div class="content">{{item.name}}</div> </li> </ul> </div> </div></template>
感谢各位的阅读,以上就是“vue+animation怎么实现跑马灯效果”的内容了,经过本文的学习后,相信大家对vue+animation怎么实现跑马灯效果这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是编程网,小编将为大家推送更多相关知识点的文章,欢迎关注!
--结束END--
本文标题: vue+animation怎么实现跑马灯效果
本文链接: https://www.lsjlt.com/news/326525.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-22
2024-05-22
2024-05-22
2024-05-22
2024-05-22
2024-05-22
2024-05-22
2024-05-21
2024-05-21
2024-05-21
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0