实现图片随鼠标移动的动态视觉差特效

效果如下

 

代码如下

 <script  src="./jq/parallax.min.js"></script>

需要使用一个js的文件

 <script>

        var scene = document.getElementById('scene');

       var parallaxInstance = new Parallax(scene);

   </script>

HTML

<div class="win">
    <div class="win-bgc1">
        <h2 class="win-zi1">LPL十年记录</h2>
        <span><a class="win-zi2" href="#">LPL名人堂</a>
            <i class="win-bgc2"></i>
    </div>
    <div class="win-lpl" >
        <div id="scene">
            <img class="layer" data-depth="0.2" src="./img/LPL十年历程.png" width="1300px" height="400px" alt="LPL十年记录">
        </div>
    </div>
</div>

CSS

.win {
    width: 100%;
    background-color: #ededed;
    padding-top: 40px;
}

.win-bgc1 {
    display: flex;
    width: 1340px;
    height: 160px;
    background-color: #ededed;
    background-image: url(../img/十年经历-title-背景.png);
    background-position: 30% 70%;
    background-repeat: no-repeat;
    background-size: 1920px 120px;
    position: relative;
    margin: 0 auto;
}

.win-zi1 {
    position: absolute;
    left: 60px;
    top: 80px;
    color: #1c2132;
}

.win-zi2 {
    position: absolute;
    right: 0;
    top: 130px;
    font-size: 12px;
    color: #1c2132;
}

.win-lpl {
    width: 1300px;
    height: 400px;
    background: url(../img/winlol-bgc.jpg) no-repeat;
    background-size: 100% 100%;
    overflow: hidden;
    margin: 0 auto;
    position: relative;
    background-attachment: fixed;
}

.win-lpl>img {
    margin: 0 auto;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值