zoukankan      html  css  js  c++  java
  • 用js实现类似分享到显示效果

    效果在左边的那个蓝色方块:进入显示的时候,会显示“分享到”几个字,鼠标移上,内容会慢慢移出,鼠标移出,内容再慢慢回复原来位置。

    分享到内容 分享到

    这个要点提示部分,在前面的几篇要点中都有提到,这里就不提了。

    下面,直接上代码喽:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="gb2312" />
    <title>无标题文档</title>
    <style>
    body
    {margin:0; padding:0; font:12px/1.5 arial;}
    #share
    {width:100px; height:200px; line-height:200px; text-align:center; border:1p solid #ccc; background:#f5f5f5; position:absolute; left:-100px; top:100px;}
    #share_tit
    {position:absolute; right:-20px; top:60px; width:20px; height:60px; padding:10px 0; background:#06c; text-align:center; line-height:18px; color:#fff;}
    </style>
    <script>
    window.onload
    = function(){
    var share = document.getElementById("share");

    share.onmouseover
    = function(){
    startrun(
    this,0)
    }

    share.onmouseout
    = function(){
    startrun(
    this,-100)
    }

    }

    var timer = null
    var speed = 0;
    function startrun(obj,target){
    clearInterval(timer);
    timer
    = setInterval(function(){

    if(obj.offsetLeft<target){
    speed
    = 10;
    }
    else{
    speed
    = -10;
    }

    if(obj.offsetLeft == target){
    clearInterval(timer);
    }
    else{
    obj.style.left
    = obj.offsetLeft + speed + "px";
    }

    },
    30)
    }
    </script>
    </head>

    <body>

    <div id="share">
    分享到内容
    <span id="share_tit">分享到</span>
    </div>

    </body>
    </html>



  • 相关阅读:
    【竞赛笔记】飞思卡尔智能车竞赛
    【实习笔记】智能广场健身设备总结
    RabbitMQ之安装
    数据结构与算法之队列
    joda-time时间操作组件
    JavaScript中的跨域问题
    数据结构与算法之链表
    Jedis集成到项目中
    ICMP协议和ping命令
    jedis的使用
  • 原文地址:https://www.cnblogs.com/jingangel/p/2392179.html
Copyright © 2011-2022 走看看