zoukankan      html  css  js  c++  java
  • 让ul li 或者table 进行循环往上滚屏

    转载:https://blog.csdn.net/u012138137/article/details/80729789

     1 <div style="display:inline">
     2 <span v-show="!showCollapse" class="icon-padding">
     3   <Icon type="ios-arrow-right"></Icon>
     4 </span>
     5 <span v-show="showCollapse" class="icon-padding">
     6   <Icon type="ios-arrow-down"></Icon>
     7 </span>
     8 </div>
     9 <!-- 上面是图标并使用div包裹显示在一行,下面是滚屏内容 -->
    10   <div  id="scroll-message" class="scroll-message-style">
    11       <ul>
    12           <li>发现CNVD-2018-01031IBM WebSphere Portal跨站脚本漏洞,请尽快自查</li>
    13           <li>跨站脚本漏洞,请尽快自查</li>
    14           <li>发现CNVD-2018-01031IBM WebSphere Portal跨站脚本漏洞,请尽快自查</li>
    15           <li>跨站脚本漏洞,请尽快自查</li>
    16           <li>发现CNVD-2018-01031IBM WebSphere Portal跨站脚本漏洞,请尽快自查</li>
    17           <li>跨站脚本漏洞,请尽快自查</li>
    18           <li>发现CNVD-2018-01031IBM WebSphere Portal跨站脚本漏洞,请尽快自查</li>
    19       </ul>
    20   </div>

    滚屏div的class样式: 
    需要注意的是overflow:hidden跟height的值一定要设定。不然不会滚屏。

    1 .scroll-message-style {
    2     overflow:hidden;
    3     height:30px;
    4     float:right;
    5     padding-right:5%;
    6 }

    接下是js相关的代码了: 
    这段定时器代码可以当独放在一个方法中执行。每次都是获取dom上的ID,这样也有个好处是在执行期间dom节点不会一直累加。

    setTimeout(function(){
          var table = document.getElementById("scroll-message");
           var timer = null;
           table.scrollTop = 0;
           table.innerHTML += table.innerHTML;
           function play() {
               clearInterval(timer);
               timer = setInterval(function() {
                   table.scrollTop++;
                   if (table.scrollTop >= table.scrollHeight / 2) {
                       table.scrollTop = 0;
                   }
               }, 100);
           }
           setTimeout(play, 500);
           table.onmouseover = function() {
               clearInterval(timer)
           };
           table.onmouseout = play;
       },0)

    下面是table相关的html代码,js代码跟上面一样的,只不过获取的dom元素ID改下就好,table头部相关的代码内容就不贴了。

     1 <div class="scroll-panel">
     2 <div class="table" id="scroll-table" style="top:0;">
     3            <table cellspacing="0" cellpadding="0">
     4                <tbody>
     5                    <tr v-for="item in list">
     6                        <td width="25%">{{item.creationTime}}</td>
     7                        <td width="25%">{{item.srcIp}}({{item.srcIpPlace}})</td>
     8                        <td width="25%">{{item.dstIp}}({{item.dstIpPlace}})</td>
     9                        <td width="15%">{{item.flowType}}</td>
    10                        <td width="10%">{{item.severityLevel|toAttackLevel}}</td>
    11                    </tr>
    12                </tbody>
    13            </table>
    14        </div>
    15    </div>
    16 
    
    18 
    
     1 /*表格*/
     2         .scroll-panel .table{
     3              100%;
     4             background-color: rgba(21, 27, 99, 0.21);
     5             position: absolute;
     6             margin: auto;
     7             top: 50px;
     8             left:0;
     9             right:0;
    10             bottom: 0;
    11         }
    12         .scroll-panel{
    13            position:relative;
    14            100%;
    15            height:100%;
    16            margin:auto;
    17            overflow:hidden;
    18         }
    19         .table{
    20             100%;
    21             height:auto;
    22             overflow: hidden;
    23         }
    24 
    
  • 相关阅读:
    mysql索引
    mysql中的事务
    mysql的各种join连接
    java集合-LinkedList源码分析
    java集合(二)-ArrayList源码分析
    java集合(一)-集合概述
    java并发(五)-重排序、 happens-before
    vue引入百度地图 --BMap is not defined ,eslint BMap报错
    红星美凯龙前端面试内容总结
    vue父子组件钩子函数的执行顺序
  • 原文地址:https://www.cnblogs.com/yun1108/p/9726302.html
Copyright © 2011-2022 走看看