jquery+css实现鼠标跟随背景视觉差异效果代码

代码语言:html

所属分类:视觉差异

代码描述:jquery+css实现鼠标跟随背景视觉差异效果代码

代码标签: 跟随 背景 视觉 差异 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<html>
<head>
    <style>
        body {
            position: relative;
            overflow: hidden;
            -webkit-perspective: 4000px;
            perspective: 4000px;
            background: none;
            font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
            text-align: center;
        }

        h2,
        h3 {
            margin: 0;
            color: rgba(255, 255, 255, 1.00);
            text-shadow: 0px 20px 10px rgba(0, 0, 0, 0.75);
        }

        h2 {
            font-size: 50px;
            line-height: 50px;
        }

        h3 {
            font-weight: 300;
        }

        .wrap {
            top: 0;
            left: 0;
            -webkit-transform-style: preserve-3d;
            transform-style: preserve-3d;
            -webkit-transform: translateZ(0);
            -ms-transform: translateZ(0);
            transform: translateZ(0);
            transition: transform 100ms linear;
            box-sizing: border-box;
            padding: 300px 30px 300px 30px;
        }

        .background {
            display: block;
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
            position: absolute;
            top: -100px;
            left: -100px;
            bottom: -100px;
            right: -100px;
            background-image: url(//repo.bfw.wiki/bfwrepo/image/5e965addb956a.png);
            background-size: cover;
            -webkit-transform: translateZ(150px);
            -ms-transform: translateZ(150px);
            transform: translateZ(150px);
        }

        .content {
            display: block;
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
            -webkit-transform: translateZ(300px);
            -ms-transform: translateZ(300px);
            transform: translateZ(300px);
            position: relative;
            overflow: hidden;
            margin: 0 auto;
            max-width: 350px;
        }
    </style>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
</head>
<body >
    <div class="wrap" style="transform: rotateX(0.692996deg) rotateY(-0.845824deg) translateZ(0px);">
        <div class="background"></div>
        <div class="content">
            <h2>3D Parallax</h2>
            <h3>Mouse Follow Animation</h3>
        </div>
    </div>
    <script>
        $(function() {
            var isMobile = window.matchMedia("only screen and (max-width: 768px)");
            var moveForce = 30; // max popup movement in pixels
            var rotateForce = 5; // max popup rotation in deg
            $(".wrap").mousemove(function(e) {
                var docX = $(this).outerWidth();
                var docY = $(this).outerHeight();

                var moveX = (e.pageX - docX / 2) / (docX / 2) * -moveForce;
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0