实现文字的上下滚动使用positon的relative的top属性,通过动态改变top来实现相关内容的更换,通过transion来实现相关的动画效果,

相关的dom内容

  1. <template>
  2. <div class="index">
  3. <div class="scroll">
  4. <ul :style="{top}" :class="{transition:index!=0}">
  5. <li v-for="(item,index) in list">
  6. {{"第"+item+"条数据"}}
  7. </li>
  8. <li>
  9. {{"第"+list[0]+"条数据"}}
  10. </li>
  11. </ul>
  12. </div>
  13. <router-link to="/">hello</router-link>
  14. </div>
  15. </template>

相关css内容

  1. img{width: 30px;height: 30px;border-radius: 50%;vertical-align: middle;margin-right: 20px}
  2. ul{position: relative;}
  3. li{overflow: hidden;white-space: nowrap; text-overflow:ellipsis;width: 80%;height: 60px;line-height: 60px;text-align: left;margin: 0;font-size: 14px}
  4. .scroll{height:60px;overflow: hidden;font-size: 0px; position: relative;}
  5. .transition{transition: top 0.5s}

相关script内容

  1. <script>
  2. export default {
  3. name: 'HelloWorld',
  4. data() {
  5. return {
  6. list: [
  7. "一","二","三","四","五","六","七","八","九","十"
  8. ],
  9. top: "",
  10. index: 0,
  11. p:""
  12. }
  13. },
  14. mounted() {
  15. this.goScroll()
  16. },
  17. methods: {
  18. goScroll() {
  19. var _this = this;
  20. this.p = setInterval(() => {
  21. console.log(22)
  22. _this.top = -60 * _this.index + 'px';
  23. if (_this.index >= this.list.length + 1) {
  24. _this.index = 0;
  25. _this.top = -0 + 'px';
  26. clearInterval(_this.p);
  27. _this.continueScroll()
  28. } else {
  29. _this.index++;
  30. }
  31. }, 1000)
  32. },
  33. continueScroll(){
  34. var _this=this;
  35. setTimeout(() => {
  36. _this.index=1;
  37. _this.top = -60 * this.index+ 'px';
  38. _this.index++
  39. this.goScroll()
  40. },100);
  41. }
  42. },
  43. destroyed(){
  44. clearInterval( this.p );
  45. }
  46. }
  47. </script>

vue实现文字上下滚动的更多相关文章

  1. 利用js来实现文字的滚动(也就是我们常常见到的新闻版块中的公示公告)

    首先先看一下大致效果图(因为是动态的,在页面无法显示出来) 具体的实现代码如下: 1.首先是css代码: <style type="text/css"> body,ul ...

  2. js 实现文字列表滚动效果

    今天要实现抽奖名单在首页滚动展示的效果,就用js写了一个,代码如下: html代码: <style type="text/css"> *{margin:;padding ...

  3. jQuery实现公告文字左右滚动

    jQuery实现公告文字左右滚动的代码. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &qu ...

  4. jquery文字上下滚动的实现方法

    jquery实现文字上下滚动的方法. 代码: //上下滚动var textRoll=function(){$('#notice p:last').css({'height':'0px','opacit ...

  5. jquery文字左右滚动

    实现jquery文字左右滚动 <div class="fl">中奖名单:</div> <div class="scrollText" ...

  6. jquery 文字向上滚动+CSS伪类before和after的应用

    汇总常用技巧——CSS伪类before和after的应用 先上效果图,建议遵循有图有真相的原则,可以上图的地方,还望不要嫌麻烦,毕竟有图的话 可以让读者少花些时间! <!DOCTYPE html ...

  7. jQuery实现公告文字左右滚动的代码。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. js文字向上滚动代码

    js文字向上滚动代码 <style>.pczt_pingfen_jhxs_news1{ width:397px;  background:#edfafd; padding-top:2px; ...

  9. js实现文字横向滚动

    页面布局      <div id="scroll_div" class="fl">         <div id="scroll ...

随机推荐

  1. java中log日志的使用(完全版)

    Commons_logging包 Apache通用日志包 他为Log4JLogger:NoOpLog:LogKitLogger:Jdk14Logger:AvalonLogger提供了一共通用的接口进行 ...

  2. Android UnitTest FrameWork

    Android test suites基于Junit,可以直接使用Junit测试不使用android api的class,也可以使用android的Junit extensions测试android ...

  3. Windows phone解决GB2312编码问题

    环境win8+vse for Windows phone 在网站http://encoding4silverlight.codeplex.com/上点击下载 之后有三个文件big5.bin,DBCSE ...

  4. Kotlin 中文文档

    Kotlin 中文文档 标签: Kotlinkotlin中文文档 2017-02-14 18:14 4673人阅读 评论(0) 收藏 举报  分类: kotlin 转载地址:http://www.tu ...

  5. sharding-jdbc,轻量级数据库分库分表中间件

    Sharding-JDBC是当当应用框架ddframe中,从关系型数据库模块dd-rdb中分离出来的数据库水平分片框架,实现透明化数据库分库分表访问.Sharding-JDBC是继dubbox和ela ...

  6. NYOJ 16 矩形嵌套【DP】

    解题思路:呃,是看的紫书上面的做法,一个矩形和另一个矩形之间的关系就只有两种,(因为它自己是不能嵌套自己的),可嵌套,不可嵌套,是一个二元关系,如果可嵌套的话,则记为1,如果不可嵌套的话则记为0,就可 ...

  7. 找出在使用临时表空间的SQL

    SELECT a.username, a.sid, a.serial#, a.osuser, b.tablespace, b.blocks, c.sql_text FROM v$session a, ...

  8. SpringBoot学习笔记(14)----应用监控-HTTP方式

    SpringBoot提供了三种应用监控的方式 通过HTTP(最简单方便) 通过JMX 通过远程shell 这里就是用最简单的方式来使用SpringBoot的应用监控 首先引入依赖,pom文件如下 &l ...

  9. 3ds Max脚本的使用实例教程

    本教程主要讲解了一个关于草地脚本的使用,应用到max与photoshop的一些命令及参数设置. 这个场景使用了3DSMAX5.1进行建模,使用VRAY渲染器进行的渲染,并且在最后使用PHOTOSHOP ...

  10. Springboot设置跨域的三种方式

    方式一(精细配置) 在需要跨域的整个Controller或者单个方法上添加@CrossOrigin注解 方式二(全局配置) @Configuration public class WebMvcConf ...