• 弹幕和回到顶部前端web


    弹幕和回到顶部前端web

    弹幕

    1.效果演示

    ceshi.gif

    2.相关代码
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>弹幕</title>
        <script src="../jquery-1.9.1/jquery-1.9.1/jquery.js"></script>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
    
            img {
    
                 50px;
                height: 50px;
    
            }
    
            .bottom {
                 100%;
                height: 80px;
                position: fixed;
                bottom: 0px;
                border: 1px solid black;
                z-index: 99;
    
            }
    
            .inner {
    
                position: absolute;
                margin-top: 15px;
                margin-left: 625px;
            }
    
            .in {
                 300px;
                height: 30px;
            }
    
            .te {
                margin-top: -45px;
                margin-left: 68px;
            }
    
            .box {
                 100%;
                height: 100%;
                border: 1px solid red;
                position: absolute;
                overflow: hidden;
            }
    
            .test{
                font-size: 20px;
                position: relative;
                /*left: 1000px;*/
                /*top: 300px;*/
    
            }
    
        </style>
    </head>
    <body>
    
    <div class="box"><span class="test">文字啊</span> </div>
    <!--弹幕-->
    <div class="bottom">
        <div class="inner">
            <img src="images/弹幕.jpg">
            <div class="te">
                <input id="txt" class="in" type="text" placeholder="请输入弹幕">
                <input type="button" value="发出">
            </div>
        </div>
    </div>
    <script>
        $(function () {
    
            $("input[type='button']").click(function () {
                var colors = ["red","yellow","blue","black","orange","pink"];
                var co = parseInt(Math.random()*colors.length);
    
                console.log($(".in").val());
                var hi = parseInt((Math.random()*400)+20);
                console.log(hi);
                var inVal = $(".in").val();
                $("<span></span>").text(inVal)
                    .addClass("test")
                    .css("color",colors[co])
                    .css("left","1000")
                    .css("top",hi)
                    .animate({left:-100},10000,"linear",function () {
                        $(this).remove();
                    })
                    .appendTo($(".box"))
                ;
               $("#txt").val("");
            });
    
    
            $(window).keyup(function (e) {
                if (e.keyCode == 13){
                    $("input[type='button']").click();
                }
    
    
            });
    
    
        })
    
    
    </script>
    
    </body>
    </html>
    

    2.回到顶部

    1.效果演示

    top.gif

    2.相关代码
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="../jquery-1.9.1/jquery-1.9.1/jquery.js"></script>
    
        <style>
            div{
                 100%;
                height: 3000px;
    
            }
            a{
                top: 500px ;
                left: 1400px;
                position: fixed;
                display: block;
                 51px;
                height: 103px;
                background: url("images/top.jpg") no-repeat -149px -96px ;
                /*border: 1px solid red;*/
                overflow: hidden;
                cursor: pointer;
            }
            a:hover{
                background: url("images/top.jpg") no-repeat -236px -96px ;
    
    
            }
    
        </style>
    </head>
    <body>
    <!--返回top的图片-->
    <a id="top"></a>
    <div></div>
    
    
    
    <script>
    
    
        $(window).scroll(function () {
    
            console.log($(window).scrollTop());
           var to =  $(window).scrollTop();
          if(to>=1500){
              $("#top").fadeIn(200);
          }else {
              $("#top").fadeOut(200);
          }
        });
    
        $("#top").click(function () {
            $("html,body").animate({scrollTop:0},1000);
        });
    
    
    </script>
    
    </body>
    </html>
    
  • 相关阅读:
    微软RPC技术学习小结
    [COM Interop学习小结]实现一个C#调用C++的示例
    [一个小问题]Mainfest配置文件的version问题小结
    【小结】IIS7下的Http Native Module开发
    Active Sync与IIS7 Classic&Integrated模式,Exchange 2007&2010的关系
    是否能在构造函数,析构函数中抛出异常?
    Trouble Shooting的一些感想(实时补充)
    python中 try、except、finally 的执行顺序
    Hessian怎样实现远程调用
    mysql的三种驱动类型
  • 原文地址:https://www.cnblogs.com/charlypage/p/9723407.html
Copyright © 2020-2023  润新知