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 ...
随机推荐
- java中log日志的使用(完全版)
Commons_logging包 Apache通用日志包 他为Log4JLogger:NoOpLog:LogKitLogger:Jdk14Logger:AvalonLogger提供了一共通用的接口进行 ...
- Android UnitTest FrameWork
Android test suites基于Junit,可以直接使用Junit测试不使用android api的class,也可以使用android的Junit extensions测试android ...
- Windows phone解决GB2312编码问题
环境win8+vse for Windows phone 在网站http://encoding4silverlight.codeplex.com/上点击下载 之后有三个文件big5.bin,DBCSE ...
- Kotlin 中文文档
Kotlin 中文文档 标签: Kotlinkotlin中文文档 2017-02-14 18:14 4673人阅读 评论(0) 收藏 举报 分类: kotlin 转载地址:http://www.tu ...
- sharding-jdbc,轻量级数据库分库分表中间件
Sharding-JDBC是当当应用框架ddframe中,从关系型数据库模块dd-rdb中分离出来的数据库水平分片框架,实现透明化数据库分库分表访问.Sharding-JDBC是继dubbox和ela ...
- NYOJ 16 矩形嵌套【DP】
解题思路:呃,是看的紫书上面的做法,一个矩形和另一个矩形之间的关系就只有两种,(因为它自己是不能嵌套自己的),可嵌套,不可嵌套,是一个二元关系,如果可嵌套的话,则记为1,如果不可嵌套的话则记为0,就可 ...
- 找出在使用临时表空间的SQL
SELECT a.username, a.sid, a.serial#, a.osuser, b.tablespace, b.blocks, c.sql_text FROM v$session a, ...
- SpringBoot学习笔记(14)----应用监控-HTTP方式
SpringBoot提供了三种应用监控的方式 通过HTTP(最简单方便) 通过JMX 通过远程shell 这里就是用最简单的方式来使用SpringBoot的应用监控 首先引入依赖,pom文件如下 &l ...
- 3ds Max脚本的使用实例教程
本教程主要讲解了一个关于草地脚本的使用,应用到max与photoshop的一些命令及参数设置. 这个场景使用了3DSMAX5.1进行建模,使用VRAY渲染器进行的渲染,并且在最后使用PHOTOSHOP ...
- Springboot设置跨域的三种方式
方式一(精细配置) 在需要跨域的整个Controller或者单个方法上添加@CrossOrigin注解 方式二(全局配置) @Configuration public class WebMvcConf ...