How to scroll diagonally with jQuery or Javascript

前端 未结 2 1094
生来不讨喜
生来不讨喜 2021-01-03 03:07

Are there projects or plugins that utilize javascript or jQuery to scroll diagonally?

e.g. when you scroll down your content, It would be pulled at the top-left corn

2条回答
  •  太阳男子
    2021-01-03 03:38

    Here's a potential solution for you (jsFiddle example):

    jQuery:

    $(window).scroll(function() {
        console.log($(this).scrollTop());
        $('#a').css({
            'width': $(this).scrollTop(),
            'height': $(this).scrollTop()
        });
        $('#b').css({
            'width': 300-$(this).scrollTop(),
            'height': 300-$(this).scrollTop()
        });
    });
    

    CSS:

    #a,#b {
        position:fixed;
        background: orange;
    }
    #a{
        top:0;
        left:0;
    }
    #b {
        bottom:0;
        right:0;
        width:300px;
        height:300px;
    }
    body {
     height:2000px;   
    }
    

    HTML:

提交回复
热议问题