zoukankan      html  css  js  c++  java
  • css跑马灯

    css3之前使用js实现

             <div style="padding: 0 1rem;">
                    <div id="container_small_tip">
                        <div id="content_small_tip"></div>
                    </div>
                </div>    
    <script>
    
    function roll(speed=1,fatherselect,select){
        if ($(fatherselect) == null) return;
        var $container = $(fatherselect);//#container_small_tip
        var $content = $(select);//#content_small_tip
        var init_left = $container.width();
        $content.css({ left: parseInt(init_left) + "px" });
        var This = this;
        var time = setInterval(function () {move($container, $content, speed); }, 20);                   //setInterval会改变this指向,即使加了This=this,也要用匿名函数封装
    
        $container.bind("mouseover", function () {
            clearInterval(time);
        });
        $container.bind("mouseout", function () {
            time = setInterval(function () {move($container, $content, speed); }, 20);
        });
        // setTimeout(function () { $("#container").slideUp(); }, 30000);  //毫秒单位,显示30s后消失
        return this;
    };
    function move($container, $content, speed){
        var container_width = $container.width();
        var content_width = $content.width();
        if (parseInt($content.css("left")) + content_width > 0) {
            $content.css({ left: parseInt($content.css("left")) - speed + "px" });
            $content.css({color:"red"})//改变字体颜色
        }
        else {
            $content.css({ left: parseInt(container_width) + "px" });
            $content.css({color:"red"})//改变字体颜色
        }
    }
    
    var content = "我是跑马灯;跑马灯是我";
    $("#content_small_tip").html(content);
    roll(2,"#container_small_tip","#content_small_tip");
    
    </script>

    使用css3 animation

     .news-move {
      position: absolute;
      top: 0;
      left: 990px;
      width: 150%;
      animation: move 25s linear 0s infinite normal ;
      cursor: pointer;
    }
    
    //鼠标hover跑马灯静止 .news-move:hover
    { animation-play-state: paused; }
  • 相关阅读:
    [转] ArcGIS自定义工具完全教程 1/2
    ArcMap工具栏中嵌入自定义按钮
    自定义ArcGIS应用程序
    制作ArcGIS DLL插件的安装包
    如何编写和注册.Net的Com组件
    空间参考(三)ArcGIS Engine的支持
    ArcGIS Desktop开发基础
    ArcGIS中坐标系统简介
    Ao开发
    ArcGIS Desktop Addin插件开发系列
  • 原文地址:https://www.cnblogs.com/ll15888/p/13303960.html
Copyright © 2011-2022 走看看