github404背景随着鼠标移动的样式实现

git地址:https://github.com/Macixsq1/github404.git
开始学前端的时候,发现了github404的页面非常有趣,当时觉得很神奇,一直不明白怎么实现的呀,最近又看到,随便想了一下,发现其实并不复杂,动手写了一个demo.
使用angularjs搭建了初步页面,实际上核心使用了原生js的操作,效果不错。
核心代码如下:
con1.js

angular.module('myapp',[])
.controller("con1",function($scope,$document){
   
    function $(id){
   
        return document.querySelector(id);
    }
    function set(elem,top,left,posX,posY,bool){
   
        if(bool){
            elem.style.top = posY+top +'px';
            elem.style.left = posX+left +'px';
        }else{
            elem.style.top = top - posY +'px';
            elem.style.left = left - posX +'px';
        }

    }
    let bgdiv = $('#bg-div'),
        img0 = $('#img0'),
        img1 = $('#img1'),
        img2 = $('#img2'),
        img3 = $('#img3'),
        img4 = $('#img4'),
        img5 = $('#img5');
    function main(posX,posY){
   
       bgdiv.style.height = 100 - posY + 'px';
       set(img0,67,62,posX,posY,true
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值