我怎样才能将div叠加到

时间:2015-09-02 07:41:26

标签: javascript background html5-canvas overlay

如何通过鼠标移动鼠标半径区域删除我的叠加背景div ,我附上我的代码进行演示...请解决任何问题并帮助我谢谢。任何人为我的网站创建这种类型的结构



    var mouseX = 0, mouseY = 0;
    $(document).mousemove(function (e) {
        mouseX = e.pageX;
        mouseY = e.pageY;
    });

    // cache the selector
    var follower = $(".follower");
    var xp = 0, yp = 0;
    var loop = setInterval(function () {
        // change 12 to alter damping higher is slower
        xp += (mouseX - xp) / 12;
        yp += (mouseY - yp) / 12;
        follower.css({ left: xp, top: yp,  opacity:1});
        //$(follower).css({  });
    }, 30);


    $(document).ready(function () {
        $(".divStick").click(function () {
            $(".divOverlay").addClass("overlayStick");
            $(this).addClass("active");

            if ($(".divOverlay").hasClass("overlay")) {
                $(".divOverlay").removeClass("overlay");
            }
            if ($(".divOverlay").hasClass("overlayShoes")) {
                $(".divShoes").removeClass("active");
                $(".divOverlay").removeClass("overlayShoes");
            }
        });

        $(".divShoes").click(function () {
            $(".divOverlay").addClass("overlayShoes");
            $(this).addClass("active");

            if ($(".divOverlay").hasClass("overlay")) {
                $(".divOverlay").removeClass("overlay");
            }
            if ($(".divOverlay").hasClass("overlayStick")) {
                $(".divOverlay").removeClass("overlayStick");
                $(".divStick").removeClass("active");
            }
        });

    });

<style>
    .txt {
    }

    .overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color:rgba(0,0,0,0.9);
        z-index: 9999;
        color: white;
        text-align: center;
    }

        .overlay:before {
            content: '';
            display: inline-block;
            height: 100%;
            vertical-align: middle;
            margin-right: -0.25em;
        }



    .overlayStick {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #000;
        z-index: 9999;
        color: white;
        text-align: center;
        font-family: Arial, Helvetica, sans-serif;
        text-decoration: none;
        cursor: url(stick2.png), auto;
    }

        .overlayStick:before {
            content: '';
            display: inline-block;
            height: 100%;
            vertical-align: middle;
            margin-right: -0.25em;
        }

    .overlayShoes {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #000;
        z-index: 9999;
        color: white;
        text-align: center;
        font-family: Arial, Helvetica, sans-serif;
        text-decoration: none;
        cursor: url(shoes.png), auto;
    }

        .overlayShoes:before {
            content: '';
            display: inline-block;
            height: 100%;
            vertical-align: middle;
            margin-right: -0.25em;
        }

    .txt {
        display: inline-block;
        vertical-align: middle;
        padding: 10px 15px;
        position: relative;
        font-weight: bold;
        background-color: #C90;
    }

        .txt:hover {
            background-color: #900;
            cursor: pointer !important;
        }
  .tx {
        display: inline-block;
        vertical-align: middle;
        padding: 10px 15px;
        position: relative;
        font-weight: bold;
        
    }
    .active {
        background-color: #900;
    }

    .new {
        display: inline-block;
        vertical-align: middle;
        padding: 10px 15px;
        position: relative;
        font-weight: bold;
    }


    .overlay2 {
        text-align: center;
    }

    .overlay2 {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0,0,0,0.8);
        z-index: 9999;
        color: white;
    }

        .overlay2:before {
            content: '';
            display: inline-block;
            height: 100%;
            vertical-align: middle;
            margin-right: -0.25em;
        }

    /*.overlay2 {
        color: #fff;
        font-family: Arial, Helvetica, sans-serif;
        text-decoration: none;
        cursor: url(shoes.png), auto;
    }*/

    .new a {
        color: #fff;
    }

    .txt a {
        color: #fff;
        font-family: Arial, Helvetica, sans-serif;
        text-decoration: none;
    }

    .follower {
        position: absolute;
        background-color: #FFFFFF;
        color: #fff;
        height: 80px;
        width: 80px;
        border-radius: 50%;
        -webkit-filter: blur(15px);
        -moz-filter: blur(15px);
        -o-filter: blur(15px);
        -ms-filter: blur(15px);
        filter: blur(15px);
    }

    /*.follower {
        position: absolute;
        background-color: #FFFFFF;
        color: #fff;
        height: 150px;
        width: 150px;
        border-radius: 50%;
        -webkit-filter: blur(15px);
        -moz-filter: blur(15px);
        -o-filter: blur(15px);
        -ms-filter: blur(15px);
        filter: blur(15px);
    }*/


 
</style>
&#13;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>

<body>

    <div class="box medium">
        <h1>overlay div remove with mouse move</h1>
        <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
        <div class="divOverlay overlay">
            <div class="txt divStick"><a href="#">Stick</a></div>
            &nbsp;
            <div class="txt divShoes"><a href="#">Shoes</a></div>
            <div class="follower"></div>
            <div class="tx">TAKE SOMEOTHER TIME </div>
        </div>
    </div>

</body>
</html>
&#13;
&#13;
&#13;

enter image description here

0 个答案:

没有答案