vue实现文字上下滚动
实现文字的上下滚动使用positon的relative的top属性,通过动态改变top来实现相关内容的更换,通过transion来实现相关的动画效果,
相关的dom内容
<template>
<div class="index">
<div class="scroll">
<ul :style="{top}" :class="{transition:index!=0}">
<li v-for="(item,index) in list">
{{"第"+item+"条数据"}}
</li>
<li>
{{"第"+list[0]+"条数据"}}
</li>
</ul>
</div>
<router-link to="/">hello</router-link>
</div>
</template>
相关css内容
img{width: 30px;height: 30px;border-radius: 50%;vertical-align: middle;margin-right: 20px}
ul{position: relative;}
li{overflow: hidden;white-space: nowrap; text-overflow:ellipsis;width: 80%;height: 60px;line-height: 60px;text-align: left;margin: 0;font-size: 14px}
.scroll{height:60px;overflow: hidden;font-size: 0px; position: relative;}
.transition{transition: top 0.5s}
相关script内容
<script>
export default {
name: 'HelloWorld',
data() {
return {
list: [
"一","二","三","四","五","六","七","八","九","十"
],
top: "",
index: 0,
p:""
}
},
mounted() {
this.goScroll()
},
methods: {
goScroll() {
var _this = this;
this.p = setInterval(() => {
console.log(22)
_this.top = -60 * _this.index + 'px';
if (_this.index >= this.list.length + 1) {
_this.index = 0;
_this.top = -0 + 'px';
clearInterval(_this.p);
_this.continueScroll()
} else {
_this.index++;
}
}, 1000)
},
continueScroll(){
var _this=this;
setTimeout(() => {
_this.index=1;
_this.top = -60 * this.index+ 'px';
_this.index++
this.goScroll()
},100);
}
},
destroyed(){
clearInterval( this.p );
}
}
</script>
vue实现文字上下滚动的更多相关文章
- 利用js来实现文字的滚动(也就是我们常常见到的新闻版块中的公示公告)
首先先看一下大致效果图(因为是动态的,在页面无法显示出来) 具体的实现代码如下: 1.首先是css代码: <style type="text/css"> body,ul ...
- js 实现文字列表滚动效果
今天要实现抽奖名单在首页滚动展示的效果,就用js写了一个,代码如下: html代码: <style type="text/css"> *{margin:;padding ...
- jQuery实现公告文字左右滚动
jQuery实现公告文字左右滚动的代码. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &qu ...
- jquery文字上下滚动的实现方法
jquery实现文字上下滚动的方法. 代码: //上下滚动var textRoll=function(){$('#notice p:last').css({'height':'0px','opacit ...
- jquery文字左右滚动
实现jquery文字左右滚动 <div class="fl">中奖名单:</div> <div class="scrollText" ...
- jquery 文字向上滚动+CSS伪类before和after的应用
汇总常用技巧——CSS伪类before和after的应用 先上效果图,建议遵循有图有真相的原则,可以上图的地方,还望不要嫌麻烦,毕竟有图的话 可以让读者少花些时间! <!DOCTYPE html ...
- jQuery实现公告文字左右滚动的代码。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js文字向上滚动代码
js文字向上滚动代码 <style>.pczt_pingfen_jhxs_news1{ width:397px; background:#edfafd; padding-top:2px; ...
- js实现文字横向滚动
页面布局 <div id="scroll_div" class="fl"> <div id="scroll ...
随机推荐
- UVALive 4223 / HDU 2962 spfa + 二分
Trucking Problem Description A certain local trucking company would like to transport some goods on ...
- Medium上的文章
Welcome to Medium, a place to read, write, and interact with the stories that matter most to you. 网站 ...
- m_Orchestrate learning system---十三、thinkphp的验证器支持多语言么
m_Orchestrate learning system---十三.thinkphp的验证器支持多语言么 一.总结 一句话总结:支持,不仅验证器支持,其它的插件应该都支持 不仅thinkphp支持多 ...
- zzulioj--1790-- 弹珠游戏(数学水题!)
弹珠游戏 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 14 Solved: 10 SubmitStatusWeb Board Descriptio ...
- 无法连接虚拟设备 ide1:0,因为主机上没有相应的设备。您要在每次开启此虚拟机时都尝试连接此虚拟设备吗?
转自:http://blog.51cto.com/thawliu/1704876 安装虚拟机时出现提示:无法连接虚拟设备 ide1:0,因为主机上没有相应的设备.您要在每次开启此虚拟机时都尝试连接此虚 ...
- sql server Delete误操作后如何恢复数据
声明:本文是根据别人的经验https://blog.csdn.net/dba_huangzj/article/details/8491327写的总结 说明:update和delete时没有加where ...
- miniUI打开一个新的画面(ondestroy)
转自:http://blog.csdn.net/u012934325/article/details/77914691 需求:开发中需求通过点击父界面一个按钮弹出一个子界面,在miniUI中我们可以这 ...
- DotNetCore.1.0.1-VS2015Tools.Preview2.0.3 相关问题及解决办法
本月16号,MS发布了 .NET Core 1.1.作为一个用贯MS产品的小盆友,我第一时间就把相关的安装包下载下来了,然后果断安装(入坑). 我猜你来看这篇博客可能遇到了和我一样的问题. 问题0:正 ...
- HDU-2204- Eddy’s爱好 (容斥原理)
题意 给出一个数n,问1-n中有多少个数可以表示为m^k,m,k均为正整数且k>1 (1<=n<=1^18) 题解 (一开始^以为是异或懵逼了好久....) 额,显然1这个数比较讨厌 ...
- [洛谷P3982]龙盘雪峰信息解析器
题目大意:给你一串代码,要求进行解码.解码规则详见题目. 解题思路:这是一道字符串处理的题目. 首先,有这么几种情况输出Error: 1.代码中出现除了0和1外的字符. 2.代码长度不是8的倍数. 3 ...