zoukankan      html  css  js  c++  java
  • 鼠标经过文字时改变该文字及其周边文字的位置

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
        <style>
            *{margin:0;padding:0;}
            .con{margin:20px auto;text-align:center;}
            .con p{display:inline-block;position:relative;cursor:pointer;width:20px;height:20px;}
        </style>
    </head>
    <body>
    <div class="con">
        <p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p>
    </div>
    <div class="con">
        <p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p>
    </div>
    <div class="con">
        <p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p>
    </div>
    <div class="con">
        <p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p>
    </div>
    <div class="con">
        <p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p>
    </div>
    </body>
    <script src="jquery-1.11.3.min.js"></script>
    <script>
        var timer;
        $(".con").find("p").hover(function(){
            clear();
            var $this=$(this);
            timer=window.setTimeout(function(){
                $this.animate({"top":"-10px"});
                $this.prev().animate({"top":"-6px"});
                $this.next().animate({"top":"-6px"});
                $this.prev().prev().animate({"top":"-2px"});
                $this.next().next().animate({"top":"-2px"});
            },100);
    
        },function(){
            clear();
            $(".con").find("p").animate({top:0});
        });
        function clear(){
            clearTimeout(timer);
            timer=null;
        }
    </script>
    </html>
  • 相关阅读:
    多列布局之等分布局
    布局之不定宽与自适应
    多列布局之一列、多列定宽及一列自适应布局
    居中布局之水平垂直布局
    JQuery 学习记录
    初遇GitHub
    关于JS中的函数定义及函数表达式
    类型识别
    页面制作(PS/HTML/CSS)易错点总结
    工欲善其事必先利其器系列之:更换Visual Studio代码风格.
  • 原文地址:https://www.cnblogs.com/dongxiaolei/p/5817632.html
Copyright © 2011-2022 走看看